how to execute multi command???

Hi every one

I'm writing C program that do the following:
will creat new sample command in unix using C
let be the name is do.c, the do must execute more the one command
for example do ls ps
it will execute ls the ps
also I should create a log file the track the command and exit status of each one
how I can do that beacuse I don't know who to start(new in UNIX and C programming)...

If this isn't homework, why can't you just write a shell script?

(We don't allow homework on the forums)

Thanks for reply...

I don't want any code..!!

I want the idea to program it
should I use int main (int argc, char *argv[])???
what argc store??? is it the number of arguments enterd??
what argv[] store?? the arguments sepreated with space??

aliG4 , what do you really want dude ?

int main (int argc, char *argv[])

-this are the parameter's of the main function ( here is a function , which return an integer value ).

argc : is the number of argument's passed , beginning with 0.

*argv[0] , *argv[1] .. : the argument's ?

Whtat does this mean ?

Let's say : ./do bla bla

./do is the 0 argument , bla is the first and second bla is the second.

So if you want to have a program do per example . You may want to execute multiple commands , and pass them like argument's.

Let's say , you want do to execute ps comand you may just enter :

 ./do ps 
  • if you want do to execute let's say ping command , you can do :
 ./do ping 

suposing , that you have configured in the program ( your C aplication ) to execute argv[1] as a command.

let's say something like system("argv[1]") .. or something like that ?

This is what do you want ? :smiley:

Thanks a lot man..

It's help a lot..