Find the answer to your Linux question:
Results 1 to 2 of 2
#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> #include <time.h> ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    98

    how to run multi system call with execl work!!


    #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>
    #include <time.h>

    int main(int argc, char **argv )
    {
    if(strcmp(argv[1],"bandwidth_cls0")==0)
    {

    execl("/bin/super","/bin/super","tc","qdisc","del","dev","eth0","root",(voi d*)NULL);
    execl("/bin/super","/bin/super","tc","qdisc","add","dev","eth0","root","han dle","1","cbq","bandwidth",argv[2],"avpkt","1000","cell","8",(void*)NULL);
    //execl("/bin/super","/bin/super","tc","class","change","dev","eth0","root"," cbq","weight",argv[2],"allot","1314",(char *)0);

    //return 0;


    }
    }

    top source code it's can run first execl only.(2nd 3rd execl except) why???

    if i want to run system call with argument and multi execl.

    please suggestion.

    thank you.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,655
    Please enclose code samples inside code blocks, and do make sure they are properly indented! Example:
    Code:
    #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>
    #include <time.h>
    
    int main(int argc, char **argv )
    {
        if(strcmp(argv[1],"bandwidth_cls0")==0)
        {
    
            execl("/bin/super","/bin/super","tc","qdisc","del","dev","eth0","root",(voi d*)NULL);
            execl("/bin/super","/bin/super","tc","qdisc","add","dev","eth0","root","han dle","1","cbq","bandwidth",argv[2],"avpkt","1000","cell","8",(void*)NULL);
            //execl("/bin/super","/bin/super","tc","class","change","dev","eth0","root"," cbq","weight",argv[2],"allot","1314",(char *)0);
        }
        return 0;
    }
    As for why only the first exec... call works is that those are functions that TRANSFORM the current executing program into the new one, so naturally, the following functions don't work. It is as though you were morphed into someone else. What was in your mind is no longer in theirs!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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