Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > how to find mac address of a remote computer?

Reply
Thread Tools

how to find mac address of a remote computer?

 
 
Jay
Guest
Posts: n/a
 
      08-13-2003
I need to write a program to find mac address of a remote computer, is
this possible? How?
 
Reply With Quote
 
 
 
 
Mark A. Odell
Guest
Posts: n/a
 
      08-13-2003
(Jay) wrote in
news: om:

> I need to write a program to find mac address of a remote computer, is
> this possible? How?


You cannot do this without platform-specific code which is off-topic here.
The C language does not provide networking support.

--
- Mark ->
--
 
Reply With Quote
 
 
 
 
David Rubin
Guest
Posts: n/a
 
      08-13-2003
Jay wrote:
>
> I need to write a program to find mac address of a remote computer, is
> this possible? How?


arp?

/david

--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown
 
Reply With Quote
 
Jirka Klaue
Guest
Posts: n/a
 
      08-13-2003
Jay wrote:
> I need to write a program to find mac address of a remote computer, is
> this possible? How?


It is possible, but you don't need to write a program, since
there is http://www.tcpdump.org.

Jirka

 
Reply With Quote
 
Jan Engelhardt
Guest
Posts: n/a
 
      08-13-2003
>I need to write a program to find mac address of a remote computer, is
>this possible? How?


Ping between both computers and run "arp" on one side if you got Linux or
similar.
 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      08-13-2003
In < > Jan Engelhardt <> writes:

>>I need to write a program to find mac address of a remote computer, is
>>this possible? How?

>
>Ping between both computers and run "arp" on one side if you got Linux or
>similar.


And you'll get the MAC address of the router, if the machines are not on
the same subnet.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email:
 
Reply With Quote
 
Lew Pitcher
Guest
Posts: n/a
 
      08-18-2003
Jay wrote:
> I need to write a program to find mac address of a remote computer, is
> this possible? How?


#include <stdio.h>

int main(void)
{
char mac_address[257];

printf("Enter the MAC address of the remote computer: ");
fflush(stdin);

fgets(mac_address,sizeof(mac_address), stdin);
if (mac_address[strlen(mac_address) - 1] == '\n')
mac_address[strlen(mac_address) - 1] = 0;

printf("The MAC address of the remote computer is %s\n",
mac_address);

return 0;
}



--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.

 
Reply With Quote
 
Joona I Palaste
Guest
Posts: n/a
 
      08-19-2003
Lew Pitcher <> scribbled the following:
> Jay wrote:
>> I need to write a program to find mac address of a remote computer, is
>> this possible? How?


> #include <stdio.h>


> int main(void)
> {
> char mac_address[257];


> printf("Enter the MAC address of the remote computer: ");
> fflush(stdin);

^^^^^^^^^^^^^
Undefined behaviour. Because of this, the program might completely
fail to display the given MAC address.

> fgets(mac_address,sizeof(mac_address), stdin);
> if (mac_address[strlen(mac_address) - 1] == '\n')
> mac_address[strlen(mac_address) - 1] = 0;


> printf("The MAC address of the remote computer is %s\n",
> mac_address);


> return 0;
> }


--
/-- Joona Palaste () ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Insanity is to be shared."
- Tailgunner
 
Reply With Quote
 
Lew Pitcher
Guest
Posts: n/a
 
      08-19-2003
Joona I Palaste wrote:
> Lew Pitcher <> scribbled the following:
>
>>Jay wrote:
>>
>>>I need to write a program to find mac address of a remote computer, is
>>>this possible? How?


>> printf("Enter the MAC address of the remote computer: ");
>> fflush(stdin);

>
> ^^^^^^^^^^^^^
> Undefined behaviour. Because of this, the program might completely
> fail to display the given MAC address.


Da*n, caught out by a typo. Of course, I meant
fflush(stdout);
but I transcribed it incorrectly.


--

Lew Pitcher, IT Consultant, Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)

 
Reply With Quote
 
PeterW
Guest
Posts: n/a
 
      10-27-2003

Originally posted by Jay

> I need to write a program to find mac address of a remote computer, is


> this possible? How?




If you can run a remote shell on the machine, you can run ifconfig and
parse the result with grep from the standard output.



> rsh remoteHost sbin/ifconfig | grep "^eth0"


eth0 Link encap:Ethernet HWaddr 00:0D:29:A8:80:44



You can use cut or awk to extract the MAC hardware address.


--
PeterW


Posted via http://dbforums.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Differnce between setting mac address port security under theinterface vs. the mac address-table global command ttripp Cisco 5 02-05-2010 10:49 PM
Remote mac address Matias Surdi Python 3 04-14-2008 03:17 PM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Wireless Networking 1 12-11-2004 09:09 PM
Detect MAC address on (remote) NIC ? Dutch Treat Computer Support 0 03-06-2004 08:34 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57