Find the answer to your Linux question:
Results 1 to 2 of 2
i'm newbie for linux programing and i program test.c in this below. #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> ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    84

    system call include parameter!!

    i'm newbie for linux programing and i program test.c in this below.

    #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],"add_rule")==0)
    {
    system("iptables -I INPUT -p tcp -m mac --mac-source $1 -m tcp --dport $2 -j DROP");
    system("iptables -I FORWARD -p tcp -m mac --mac-source $1 -m tcp --dport $2 -j DROP");
    }

    test 00:00:00:00:00:00 172.168.1.100

    after use that command iptables it's add INPUT,FORWARD

    how to !!! help me it's code not working..!!

    thank you for help me.

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Hello,

    the system function does not do variable substitution. You want to use sprintf.
    Debian GNU/Linux -- You know you want it.

Posting Permissions

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