Possible Duplicate:
Running a shell command in a c program
I am running a shell script from C.It is executed using system().How to pass parameters to this script?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
systemtakes a single string containing the entire command line, so you’d passIt is rarely a good idea to use
system, because you’ll have to escape all meta-characters yourself – even spaces are a problem, as you can see above. You’re looking for one of the exec* functions, for example execv. Its first argument is the name of the program (in your case/bin/shor the shell script itself), its second is a NULL-terminated list of argument strings: