Find the answer to your Linux question:
Results 1 to 6 of 6
#### test.c##### #include <fcntl.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <netinet/in.h> #include <net/if.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    84

    c programing with linux command!!

    #### test.c#####

    #include <fcntl.h>
    #include <string.h>
    #include <sys/stat.h>
    #include <sys/types.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <sys/ioctl.h>
    #include <netinet/in.h>
    #include <net/if.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>

    int main(int argc, char **argv )
    {

    if(strcmp(argv[1],"mac_arp")==0)
    {
    system("/usr/local/bin/naxclassv2 access arp -en | grep $1 | awk '{print $3}'");
    }

    }

    i use c programing for call system command on linux fedora and how to call argv ($1) for filter mac address


    test mac_arp 172.168.1.200
    result it's show mac address of 172.168.1.200

    i can try this it's not working. please help me

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    452
    are you calling your program "test"?
    the problem is, /usr/bin/test will be run,
    unless you say "./test" or else use another
    name
    the sun is new every day (heraclitus)

  3. #3
    Just Joined!
    Join Date
    Jun 2007
    Posts
    84
    Quote Originally Posted by tpl View Post
    are you calling your program "test"?
    the problem is, /usr/bin/test will be run,
    unless you say "./test" or else use another
    name
    no no!! i can call test it working. but argv include not working.

  4. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    in your if statement try:

    if(!strcmp(argv[1],"mac_arp"))

    I think this is what you want

  5. #5
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    in your if statement try:

    if(!strcmp(argv[1],"mac_arp"))

    I think this is what you want
    No, that won't change the behavior of his program.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  6. #6
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Ooops...Gerard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...