Archive: Exec and command line redirects?


Exec and command line redirects?
OK, I've been fighting this one all afternoon.

I need to execute the command line

mkpasswd -l >> passwd

mkpasswd lives in $INSTDIR\bin, and I really want the file to land in $INSTDIR\etc, but I can't even get that far. mkpasswd just prints to stdout and I need to get that into a file.

No matter what combination of quoting (and I've tried a lot) I use, I always get either silent failure or "mkpasswd: a domain is only accepted when -d is given"

In other words, the '>>' is being interpreted as a parameter to mkpasswd, not as a redirect.

I've read a dozen threads on similar and I can't figure this one out.

I really want to say

nsExec::ExecToLog '$INSTDIR\bin\mkpasswd -l >> $INSTDIR\etc\passwd'

with whatever additional quoting/escaping/chanting/cursing is necessary to make it work.

Any guidance would be appreciated.

Thanks,
Zandr


You must use the command line interpreter to use redirection. Use petersa's method in this thread:

http://forums.winamp.com/showthread....ighlight=mysql

Don't forget to use short file names for the command line interpreter. Use GetFullPathName /SHORT if the path is dynamic (includes $INSTDIR like in your case, for example).


Thanks kichik!

I ended up working around this last night by invoking .bat files, but this is easier to maintain.

Thanks again,
Z


Could someone post a WORKING solution for exactly that?
I can't figure out, how the command
mkpasswd -l >> passwd
should work from NSIS and write the 'passwd' to the standard-etc-directory.


ReadEnvStr $0 COMSPEC
ExecWait "$0 /c mkpasswd -l >> passwd"