Archive: Problem executing long command


Problem executing long command
I'm trying to execute a bunch of MySQL commands I've put into a file (batch.txt). I can't seem to get Execdos to execute it properly


ExecDos::exec /TIMEOUT=5000 "$INSTDIR\mysql\bin\mysql.exe --user=root --password=cacti --database=cacti < $TEMP\batch.txt" "" "$INSTDIR\Inetpub\wwwroot\cacti\log\rrdtoolpath.log"
Pop $0 ; exit code
MessageBox MB_OK "Exit code $0"


or

ExecDos::exec /TIMEOUT=5000 '"$INSTDIR\mysql\bin\mysql.exe" --user=root --password=cacti --database=cacti < $TEMP\batch.txt' "" "$INSTDIR\Inetpub\wwwroot\cacti\log\rrdtoolpath.log"
Pop $0 ; exit code
MessageBox MB_OK "Exit code $0"


Do not work. The output simply lists the MySQL commands. Is there any way I can see what execdos is trying to do?

Bah, fixed it:


ExecCmd::exec /TIMEOUT=5000 "$INSTDIR\mysql\bin\mysql.exe --user=root --password=cacti --database=cacti < $TEMP\batch.txt" ""

Input redirection is a shell option so you can add:


ReadEnvStr $R0 COMSPEC
ExecDos::exec '$R0 /C /TIMEOUT=5000 '"$INSTDIR\mysql...

to your command line (%COMSPEC% not worked here in my tests). ExecCmd adds comspec by default.

Make sure you put quotes around the path to execute:

'"$INSTDIR\mysql\bin\mysql.exe" --user=root --password=cacti --database=cacti < "$TEMP\batch.txt"' ""


If $INSTDIR or $TEMP contain spaces your command will likely fail.
E.g. if $INSTDIR is C:\Program Files\MyApp, then without the quotes, ExecDos will try to execute "C:\Program" which isn't a file, nor even a folder!

-Stu