humgut
17th December 2002 21:07 UTC
ExecWait with file redirection
Hi,
Trying to use ExecWait (NSIS2, ModernUI) in a section to redirect external program output to file:
SetOutPath $INSTDIR
File "memory.exe"
ExecWait '"$INSTDIR\memory.exe" > "$INSTDIR\memory.txt"' $0
IfErrors e1 e2
e1:
MessageBox MB_OK "Error = $0"
goto e3
e2:
MessageBox MB_OK "OK"
e3:
ExecWait returns no error, yet file is not created. Any ideas?
Thanks.
kichik
17th December 2002 21:25 UTC
This thread should help you:
http://forums.winamp.com/showthread....ighlight=mysql
BTW, you might also want to try out nsExec, maybe it can help you too.
humgut
18th December 2002 14:33 UTC
Thanks for the link Kichik.
Here is the the code that worked for me:
ExpandEnvStrings $1 %COMSPEC%
ExecWait '"$1" /C "$INSTDIR\memory.exe" > "$INSTDIR\mem.txt"' $0
treaz
13th January 2003 17:26 UTC
Hi,
I guess I have a some-what similar problem.
I am trying to pipe my output to a log file and I have attempt the below 3 options but none of them creates the test.log file.
Could someone please help. Thanks.
ExecWait 'call "$INSTDIR\test.bat" "2> $INSTDIR\test.log"' $0
ExecWait 'call "$INSTDIR\test.bat" 2> "$INSTDIR\test.log"' $0
ExecWait "call $INSTDIR\test.bat 2> $INSTDIR\test.log" $0
:(
kichik
13th January 2003 17:31 UTC
Use the code above:
ExpandEnvStrings $1 %COMSPEC%
ExecWait '"$1" /C "$INSTDIR\test.bat" > "$INSTDIR\test.log"' $0
blmille1
12th June 2009 23:25 UTC
Originally posted by kichik
Use the code above:
ExpandEnvStrings $1 %COMSPEC%
ExecWait '"$1" /C "$INSTDIR\test.bat" > "$INSTDIR\test.log"' $0
Every time I put double quotes around the output file I get an errorlevel of 1.
After about try 1038 I decided to try taking the quotes out.
It started working.
strcpy $BACKUPFILE "$TEMP\ADMIN_DB_MYSQL_BACKUP.sql"
strcpy $BACKUPFILE_PREPARED "$TEMP\ADMIN_DB_MYSQL_BACKUP_PREPARED.sql"
strcpy $1 $BACKUPFILE
ExpandEnvStrings $2 %COMSPEC%
Before:
ExecWait '"$2" /C "$INSTDIR\bin\mysqldump.exe" --quick --add-drop-table --extended-insert --force --user=username --password=password database > "$1"' $0
After:
ExecWait '"$2" /C "$INSTDIR\bin\mysqldump.exe" --quick --add-drop-table --extended-insert --force --user=username --password=password database > $1' $0
The reason I resorted to $1 instead of $BACKUPFILE was that I thought variable expansion wasn't working correctly, so sorry for the unnecessary confusion.
Any reason why the first attempt didn't work?
Thanks!
Brandon
kichik
12th June 2009 23:42 UTC
cmd.exe sucks, though probably for a reason. Add a IF 1==1 prefix to your command.
ExecWait '"$2" /C IF 1==1 "$INSTDIR..." ...