Connecting Tech Pros Worldwide Forums | Help | Site Map

how to find mac address of a remote computer?

Jay
Guest
 
Posts: n/a
#1: Nov 13 '05
I need to write a program to find mac address of a remote computer, is
this possible? How?

Mark A. Odell
Guest
 
Posts: n/a
#2: Nov 13 '05

re: how to find mac address of a remote computer?


jay4050@hotmail.com (Jay) wrote in
news:6ddc1590.0308130521.686e5093@posting.google.c om:
[color=blue]
> I need to write a program to find mac address of a remote computer, is
> this possible? How?[/color]

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

--
- Mark ->
--
David Rubin
Guest
 
Posts: n/a
#3: Nov 13 '05

re: how to find mac address of a remote computer?


Jay wrote:[color=blue]
>
> I need to write a program to find mac address of a remote computer, is
> this possible? How?[/color]

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
Jirka Klaue
Guest
 
Posts: n/a
#4: Nov 13 '05

re: how to find mac address of a remote computer?


Jay wrote:[color=blue]
> I need to write a program to find mac address of a remote computer, is
> this possible? How?[/color]

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

Jirka

Jan Engelhardt
Guest
 
Posts: n/a
#5: Nov 13 '05

re: how to find mac address of a remote computer?


>I need to write a program to find mac address of a remote computer, is[color=blue]
>this possible? How?[/color]

Ping between both computers and run "arp" on one side if you got Linux or
similar.
Dan Pop
Guest
 
Posts: n/a
#6: Nov 13 '05

re: how to find mac address of a remote computer?


In <Pine.LNX.4.53.0308131641120.10156@yvahk01.tjqt.qr > Jan Engelhardt <jengelh@linux01.gwdg.de> writes:
[color=blue][color=green]
>>I need to write a program to find mac address of a remote computer, is
>>this possible? How?[/color]
>
>Ping between both computers and run "arp" on one side if you got Linux or
>similar.[/color]

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: Dan.Pop@ifh.de
Lew Pitcher
Guest
 
Posts: n/a
#7: Nov 13 '05

re: how to find mac address of a remote computer?


Jay wrote:[color=blue]
> I need to write a program to find mac address of a remote computer, is
> this possible? How?[/color]

#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.

Joona I Palaste
Guest
 
Posts: n/a
#8: Nov 13 '05

re: how to find mac address of a remote computer?


Lew Pitcher <lpitcher@sympatico.ca> scribbled the following:[color=blue]
> Jay wrote:[color=green]
>> I need to write a program to find mac address of a remote computer, is
>> this possible? How?[/color][/color]
[color=blue]
> #include <stdio.h>[/color]
[color=blue]
> int main(void)
> {
> char mac_address[257];[/color]
[color=blue]
> printf("Enter the MAC address of the remote computer: ");
> fflush(stdin);[/color]
^^^^^^^^^^^^^
Undefined behaviour. Because of this, the program might completely
fail to display the given MAC address.
[color=blue]
> fgets(mac_address,sizeof(mac_address), stdin);
> if (mac_address[strlen(mac_address) - 1] == '\n')
> mac_address[strlen(mac_address) - 1] = 0;[/color]
[color=blue]
> printf("The MAC address of the remote computer is %s\n",
> mac_address);[/color]
[color=blue]
> return 0;
> }[/color]

--
/-- Joona Palaste (palaste@cc.helsinki.fi) ---------------------------\
| 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
Lew Pitcher
Guest
 
Posts: n/a
#9: Nov 13 '05

re: how to find mac address of a remote computer?


Joona I Palaste wrote:[color=blue]
> Lew Pitcher <lpitcher@sympatico.ca> scribbled the following:
>[color=green]
>>Jay wrote:
>>[color=darkred]
>>>I need to write a program to find mac address of a remote computer, is
>>>this possible? How?[/color][/color][/color]
[color=blue][color=green]
>> printf("Enter the MAC address of the remote computer: ");
>> fflush(stdin);[/color]
>
> ^^^^^^^^^^^^^
> Undefined behaviour. Because of this, the program might completely
> fail to display the given MAC address.[/color]

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)

PeterW
Guest
 
Posts: n/a
#10: Nov 13 '05

re: how to find mac address of a remote computer?



Originally posted by Jay
[color=blue]
> I need to write a program to find mac address of a remote computer, is[/color]
[color=blue]
> this possible? How?[/color]



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


[color=blue]
> rsh remoteHost sbin/ifconfig | grep "^eth0"[/color]

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
Joona I Palaste
Guest
 
Posts: n/a
#11: Nov 13 '05

re: how to find mac address of a remote computer?


PeterW <member45765@dbforums.com> scribbled the following:[color=blue]
> Originally posted by Jay[color=green]
>> I need to write a program to find mac address of a remote computer, is
>> this possible? How?[/color][/color]
[color=blue]
> If you can run a remote shell on the machine, you can run ifconfig and
> parse the result with grep from the standard output.[/color]
[color=blue][color=green]
>> rsh remoteHost sbin/ifconfig | grep "^eth0"[/color]
> eth0 Link encap:Ethernet HWaddr 00:0D:29:A8:80:44[/color]
[color=blue]
> You can use cut or awk to extract the MAC hardware address.[/color]

Which part of this had anything at all to do with C?

--
/-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"That's no raisin - it's an ALIEN!"
- Tourist in MTV's Oddities
Glen Herrmannsfeldt
Guest
 
Posts: n/a
#12: Nov 13 '05

re: how to find mac address of a remote computer?



"Joona I Palaste" <palaste@cc.helsinki.fi> wrote in message
news:bnil6s$63n$1@oravannahka.helsinki.fi...[color=blue]
> PeterW <member45765@dbforums.com> scribbled the following:[color=green]
> > Originally posted by Jay[color=darkred]
> >> I need to write a program to find mac address of a remote computer, is
> >> this possible? How?[/color][/color]
>[color=green]
> > If you can run a remote shell on the machine, you can run ifconfig and
> > parse the result with grep from the standard output.[/color]
>[color=green][color=darkred]
> >> rsh remoteHost sbin/ifconfig | grep "^eth0"[/color]
> > eth0 Link encap:Ethernet HWaddr 00:0D:29:A8:80:44[/color]
>[color=green]
> > You can use cut or awk to extract the MAC hardware address.[/color]
>
> Which part of this had anything at all to do with C?[/color]

ifconfig, grep, cut, and awk are all C programs.

-- glen


Joona I Palaste
Guest
 
Posts: n/a
#13: Nov 13 '05

re: how to find mac address of a remote computer?


Glen Herrmannsfeldt <gah@ugcs.caltech.edu> scribbled the following:[color=blue]
> "Joona I Palaste" <palaste@cc.helsinki.fi> wrote in message
> news:bnil6s$63n$1@oravannahka.helsinki.fi...[color=green]
>> PeterW <member45765@dbforums.com> scribbled the following:[color=darkred]
>> > Originally posted by Jay
>> >> I need to write a program to find mac address of a remote computer, is
>> >> this possible? How?[/color]
>>[color=darkred]
>> > If you can run a remote shell on the machine, you can run ifconfig and
>> > parse the result with grep from the standard output.[/color]
>>[color=darkred]
>> >> rsh remoteHost sbin/ifconfig | grep "^eth0"
>> > eth0 Link encap:Ethernet HWaddr 00:0D:29:A8:80:44[/color]
>>[color=darkred]
>> > You can use cut or awk to extract the MAC hardware address.[/color]
>>
>> Which part of this had anything at all to do with C?[/color][/color]
[color=blue]
> ifconfig, grep, cut, and awk are all C programs.[/color]

But this newsgroup is about C, not C programs.

--
/-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Immanuel Kant but Genghis Khan."
- The Official Graffitist's Handbook
Mark McIntyre
Guest
 
Posts: n/a
#14: Nov 13 '05

re: how to find mac address of a remote computer?


On Mon, 27 Oct 2003 19:52:05 GMT, in comp.lang.c , "Glen
Herrmannsfeldt" <gah@ugcs.caltech.edu> wrote:
[color=blue]
>
>"Joona I Palaste" <palaste@cc.helsinki.fi> wrote in message[/color]
[color=blue][color=green]
>> Which part of this had anything at all to do with C?[/color]
>
>ifconfig, grep, cut, and awk are all C programs.[/color]

Says who? Maybe they're written in Fortran on the OP's platform.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Closed Thread