Hello forum,
With my installer I install a mysql database.
After installation a table should be updated. (A directory path)
If I do it in this way the update is not be done.
------------------------------------------------
Section "UpdateMySQLDatabase"
SetOutPath $TEMP
FileOpen $0 updatedir.sql w
FileWrite $0 "UPDATE directoriestable SET RootDirectoriesPath='$Mod_INSTDIR2' WHERE RootDirectoriesKeyName='DirectoriesMain';$\r$\n"
FileClose $0
ExecWait '"$INSTDIR\mysql\bin\mysql.exe" -uroot -ppassword -Dtestdb < "$TEMP\updatedir.sql"'
SectionEnd
-----------------------------------------------------
The command ;
ExecWait '"$INSTDIR\mysql\bin\mysql.exe" -uroot -ppassword -Dtestdb < "$TEMP\updatedir.sql"'
is wrong or is not be executed.
But if I put the same into a batch file and execute this, all works fine.
-------------------------------------------------------
Section "UpdateMySQLDatabase"
SetOutPath $TEMP
FileOpen $0 updatedir.sql w
FileWrite $0 "UPDATE directoriestable SET RootDirectoriesPath='$Mod_INSTDIR2' WHERE RootDirectoriesKeyName='DirectoriesMain';$\r$\n"
FileClose $0
FileOpen $0 updatedir.bat w
FileWrite $0 "@echo off $\r$\n"
FileWrite $0 '"$INSTDIR\mysql\bin\mysql.exe" -uroot -ppassword -Dtestdb < "$TEMP\updatedir.sql"'
FileClose $0
ExecWait "$TEMP\updatedir.bat";
SectionEnd
------------------------------------------------------
Two questions:
1. What is wrong with the first version without the batch file?
2. How can I debug the ExecWait "Dos" window?
I see that there is an error in it, but the messages are so quick that I cannot read it and the window will be closed quickly.
Is there any way to pause the ExecWait or is there an option to debug the ExecWait or the complete installer script with all output?
thanks a lot
regards
hawk
ExecWait Update Mysql not work, Batch file ok
8 posts
Piping can only be done in command prompt (or cmd /C command < input.txt). Use nsExec::Exec to hide the window:
ReadEnvStr $R0 COMSPEC
nsExec::Exec `"$R0" /C ...`
Stu
ReadEnvStr $R0 COMSPEC
nsExec::Exec `"$R0" /C ...`
Stu
Hi Stu,
thanks a lot for your help.
If I understand it right, with Exec or ExecWait you cannot execute a command with < or > or || ?
So you always need a batch file for this?
What do you mean with "Use nsExec::Exec to hide the window"?
I dont want to hide a window. My 2. question was how to see the error messages or how to debug if Exec window shows errors.
thanks a lot
regards
hawk
thanks a lot for your help.
If I understand it right, with Exec or ExecWait you cannot execute a command with < or > or || ?
So you always need a batch file for this?
What do you mean with "Use nsExec::Exec to hide the window"?
I dont want to hide a window. My 2. question was how to see the error messages or how to debug if Exec window shows errors.
thanks a lot
regards
hawk
Exec and ExecWait do not use cmd.exe to run programs. No you don't have to use a batch file - read my post again. If you don't want to hide the command prompt window then don't use nsExec.
Stu
Stu
Check the error level (exit code) of the ran command to detect errors. See ExecWait in the manual for more information.
Stu
Stu
Hi Stu,
I searched with google and also in the NSIS wiki and in the scripting reference doku.
Where can I find info and usage docu about
nsExec ?
regards
hawk
I searched with google and also in the NSIS wiki and in the scripting reference doku.
Where can I find info and usage docu about
nsExec ?
regards
hawk
NSIS\Docs\nsExec
Stu
Stu
This is probably what you are after:
Stu
COMSPEC is the environment variable containing the path to cmd.exe.ReadEnvStr $R0 COMSPEC
nsExec::Exec '"$R0" /C "$INSTDIR\mysql\bin\mysql.exe" -uroot -ppassword -Dtestdb < "$TEMP\updatedir.sql"'
Stu