Skip to content
⌘ NSIS Forum Archive

command line input piping

8 posts

Kolya#

command line input piping

Hey there.
I'm trying to pipe a password file into rsync. It works fine on the dos command line (rsync<passwordfile), but I have yet to get it to work via NSIS. I tried nsexec and execdos. The latter seemed promising but ultimately didn't work. I fed it the path to the password file in the second parameter, but rsync still waits for input.

Any help would be appreciated.
Anders#
If you are using nsExec then you have to execute 'cmd.exe /c "c:\path\yourapp.exe" < "c:\path\somefile.ext"' etc
Kolya#
I tried that before but ended up with a message from CMD: "Input line is too long". Unfortunately there is not much I can do about the length of paths on a foreign system.
Anders#
| < and > are handled by cmd.exe, maybe try a batchfile and/or 8.3 short paths?

IIRC one of the exec plugins on the wiki has custom stdin handling which might be worth a shot...
Kolya#
I noticed that I get the "Input line is too long" error whenever I add double quotes around the path to the file that is piped into rsync.

I found that this is an old windows bug, the solution is here: http://stackoverflow.com/questions/6...answer-3583282

The syntax that actually works is therefore:
nsExec::ExecToLog 'cmd.exe /c ""C:/path/to/program.exe" parameters < "C:/path/to/input-file.txt""'

In other words, the command that is handed to cmd.exe should be wrapped in another pair of double quotes.
Kolya#
Interesting, that works as well. So it's the same bug.
On further inspection it seems to be enough to place only the first double quote before the command:
nsExec::ExecToLog 'cmd.exe /c ""program" parameters < "input-file"'

I wouldn't be surprised if there are more solutions to this. The extra quote is certainly the shortest, but I do like the if 1==1 solution, because it's an obvious workaround. Whereas juggling quotes could easily be interpreted as a typo by another person working on the code.