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");
The
execlfunction 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: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.