Reputation: 7494
Using cygwin on Windows 7, need to:
cmd
START
)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.
Upvotes: 1
Views: 1016
Reputation: 2013
Try one of the following:
start 'executableFileName -f -n 100 > logFilePath.txt'
cmd //c 'executableFileName -f -n 100 > logFilePath.txt'
Cygwin comes with a very interesting /usr/bin/start
script, which basically calls cmd /c start [args]
for you.
I found out that //c
becomes /c
when calling a native Windows program. Take a look at the difference:
user@pc:~ $ cmd //c echo /c //c
C:/ /c
Upvotes: 0
Reputation: 2013
If you really need cmd
to run the command, I think the best you can do is:
powershell -c 'cmd /c "executableFileName -f -n 100 > logFilePath.txt"'
When calling Windows programs, cygwin translates /C
to C:\
(like start /b program
--> start B:\ program
). This messes things up.
Since powershell accepts -c
instead of /c
, it works. Inside its command, you can use /c
safely.
Upvotes: 0
Reputation: 130849
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
Upvotes: 1