linux - send mulitple args to system() in C -


Suppose I have a line bash script that executes in all the arguments

 < code> #! / Bin / bash $ 1   

Then, the command ./ one_line_script.sh "ls -lh" works fine except that I have a code which is Accept logic and sends them to my bass script

  int main (int argc, char * argv []) {char command [1000]; Sprintf (command, "/ path / to / one_line_scripts.ss% s", RGR [1]); System (order); Return 0; }   

And I have a problem here, because ./ c_program "ls -lh" gives only ls outputs some arguments Do not understand how I need to modify my code, so can it accept some arguments?

I have issues with fork and exec For example, to avoid completely quote, consider for example that if any ' is contained within an argument - when sprintf is doing the CMD-line, but it The cutting line breaks if the cutting line is broken.

  int pud = fork (); If (pid == 0) {execl ("/ bin / sh", "sh", "-c", arg1, arg2, arg3, 0); } Else {int position = 0; Waiting Speed ​​(Peed, and Position, 0); }    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -