Monday, May 24, 2010

How can make system call in c++ using the process and exec function?

please help , i have assignment. and i don't know how to solve it . my assignment is to make shell that make all commend like (ls , mkdir , mkfile ... elc) i don't know ho to use the exec function please i want any example to show me how to use this function to run the command . please very fast , thanks in advance

How can make system call in c++ using the process and exec function?
I'm writing in C for "ls -l" command, okay ?





main()


{


if (fork() == 0)


{


execl("/bin/ls","ls","-l", (char *)0 ) ;


}


else


{


wait (0) ;


execl("/bin/ls","ps", (char *)0 ) ;


}


}
Reply:system("mkdir asdf);


No comments:

Post a Comment