Reputation: 3784
I've seen many many results for unix systems. I am using cygwin so I am using unistd.h
library. I am trying to run this command but It does not run. What could I be missing here?
execl("C:\\WINDOWS\\SYSTEM32\\CMD.EXE", "/c echo foo>C:\\Users\\Sarp\\Desktop\\foo.txt");
Upvotes: 1
Views: 16572
Reputation: 5602
The execl
function call does not split the arguments for you. This basically means that you need to separate each command line argument as a different string parameter when invoking the function. For example:
execl("C::\\WINDOWS\\SYSTEM32\\CMD.EXE", "cmd.exe", "/c",
"echo", "foo", ">C:\\Users\\Sarp\\Desktop\\foo.txt")
However, I'm under the impression that the output redirection may not work (depending on how the Windows shell interprets those), so I encourage you to try the system()
function which resembles your usage case more closely.
Upvotes: 3