how to find mac address of a remote computer?

Discussion in 'C Programming' started by Jay, Aug 13, 2003.

  1. Jay

    Jay Guest

    I need to write a program to find mac address of a remote computer, is
    this possible? How?
    Jay, Aug 13, 2003
    #1
    1. Advertising

  2. (Jay) wrote in
    news::

    > 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 ->
    --
    Mark A. Odell, Aug 13, 2003
    #2
    1. Advertising

  3. Jay

    David Rubin Guest

    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
    David Rubin, Aug 13, 2003
    #3
  4. Jay

    Jirka Klaue Guest

    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
    Jirka Klaue, Aug 13, 2003
    #4
  5. >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.
    Jan Engelhardt, Aug 13, 2003
    #5
  6. Jay

    Dan Pop Guest

    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:
    Dan Pop, Aug 13, 2003
    #6
  7. Jay

    Lew Pitcher Guest

    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.
    Lew Pitcher, Aug 18, 2003
    #7
  8. 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
    Joona I Palaste, Aug 19, 2003
    #8
  9. Jay

    Lew Pitcher Guest

    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)
    Lew Pitcher, Aug 19, 2003
    #9
  10. Jay

    PeterW Guest

    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
    PeterW, Oct 27, 2003
    #10
  11. PeterW <> scribbled the following:
    > 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.


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

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "That's no raisin - it's an ALIEN!"
    - Tourist in MTV's Oddities
    Joona I Palaste, Oct 27, 2003
    #11
  12. "Joona I Palaste" <> wrote in message
    news:bnil6s$63n$...
    > PeterW <> scribbled the following:
    > > 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.

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


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

    -- glen
    Glen Herrmannsfeldt, Oct 27, 2003
    #12
  13. Glen Herrmannsfeldt <> scribbled the following:
    > "Joona I Palaste" <> wrote in message
    > news:bnil6s$63n$...
    >> PeterW <> scribbled the following:
    >> > 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.

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


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


    But this newsgroup is about C, not C programs.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "Immanuel Kant but Genghis Khan."
    - The Official Graffitist's Handbook
    Joona I Palaste, Oct 27, 2003
    #13
  14. On Mon, 27 Oct 2003 19:52:05 GMT, in comp.lang.c , "Glen
    Herrmannsfeldt" <> wrote:

    >
    >"Joona I Palaste" <> wrote in message


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

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


    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 =---
    Mark McIntyre, Oct 27, 2003
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arun

    Find MAC address.

    Arun, Nov 3, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    7,106
    John Saunders
    Nov 4, 2003
  2. UJ
    Replies:
    4
    Views:
    700
    John Rivers
    Sep 2, 2005
  3. SJ

    MAC Address/Physical Address?

    SJ, Jan 7, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    504
  4. Daniel T.

    How to find MAC address and uids?

    Daniel T., Nov 10, 2004, in forum: Python
    Replies:
    4
    Views:
    3,833
    Mike Hall
    Nov 10, 2004
  5. Matias Surdi

    Remote mac address

    Matias Surdi, Apr 14, 2008, in forum: Python
    Replies:
    3
    Views:
    421
    Frank Stutzman
    Apr 14, 2008
Loading...

Share This Page