Find the answer to your Linux question:
Results 1 to 3 of 3
i want to compare with command line system("arp -en | grep eth1 | wc -l"); --> result about = 4 compare with system("arp -en | grep eth0 | wc -l"); ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    84

    anyone help me!! i want compare system call with c programing.

    i want to compare with command line

    system("arp -en | grep eth1 | wc -l"); --> result about = 4

    compare with

    system("arp -en | grep eth0 | wc -l"); --> result about = 10

    ** i want to compare result (integer) command between command1 and command2


    How to programing with C on linux.

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Lightbulb

    Quote Originally Posted by slackman View Post
    i want to compare with command line

    system("arp -en | grep eth1 | wc -l"); --> result about = 4

    compare with

    system("arp -en | grep eth0 | wc -l"); --> result about = 10

    ** i want to compare result (integer) command between command1 and command2


    How to programing with C on linux.
    i'm not sure whether i understood ur problem...
    in case you want to display the difference between two commands
    try ,
    #arp -en | grep eth0 > file1
    #arp -en | grep eth1 > file2
    #diff file1 file2

    You can use these with in system() function.
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  3. #3
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    You can accomplish this with the popen() function. An example of popen():

    Code:
    #include <stdio.h>
    main()
    {
      FILE *fp;
      char line[128];
       
      fp = popen("arp -en | grep eth1 | wc -l", "r");
    
      while ( fgets( line, sizeof line, fp))
      {
        printf("&#37;s", line);
      }
      pclose(fp);
    }
    Regards

Posting Permissions

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