Skip to content
⌘ NSIS Forum Archive

Exec and command line redirects?

5 posts

n6mod#

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
kichik#
You must use the command line interpreter to use redirection. Use petersa's method in this thread:

Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.


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).
n6mod#
Thanks kichik!

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

Thanks again,
Z
Guest#
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.