cmdcygwin

Using cygwin to netively execute cmd command and redirect stdout


Using cygwin on Windows 7, need to:

I've tried (executed in cygwin):

cmd /C "START cmd /C \"executableFileName -f -n 100 > logFilePath.txt\""

And many variations of the above line, but nothing worked.


Solution

  • I don't have cygwin, so I cannot test. But try the following.

    cmd /c start cmd /c "executableFileName -f -n 100 >logFilePath.txt"
    

    The quotes around the command following /c are not required, so you don't need them in the first cmd /c. They are useful in the second cmd /c to prevent the redirection from activating until the final cmd is executed.

    Regarding your original code - the escape character for cmd.exe is ^, not \, and you cannot escape a quote once quoting has begun. That is why I opted not to include any quotes in the outer most cmd /c