Old 17th December 2002, 20:07   #1
humgut
Junior Member
 
Join Date: Oct 2002
Location: Canada
Posts: 5
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.
humgut is offline   Reply With Quote
Old 17th December 2002, 20:25   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 18th December 2002, 13:33   #3
humgut
Junior Member
 
Join Date: Oct 2002
Location: Canada
Posts: 5
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
humgut is offline   Reply With Quote
Old 13th January 2003, 16:26   #4
treaz
Member
 
Join Date: Jan 2003
Posts: 78
Unhappy

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


treaz is offline   Reply With Quote
Old 13th January 2003, 16:31   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Use the code above:

ExpandEnvStrings $1 %COMSPEC%
ExecWait '"$1" /C "$INSTDIR\test.bat" > "$INSTDIR\test.log"' $0

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 12th June 2009, 22:25   #6
blmille1
Junior Member
 
Join Date: Jun 2009
Posts: 1
Quote:
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
blmille1 is offline   Reply With Quote
Old 12th June 2009, 22:42   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
cmd.exe sucks, though probably for a reason. Add a IF 1==1 prefix to your command.
code:
ExecWait '"$2" /C IF 1==1 "$INSTDIR..." ...

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump