Skip to content
⌘ NSIS Forum Archive

execshell problem

10 posts

Darktrain#

execshell problem

Hello,

ive got a question about using execshell.

-ExecShell open '"$INSTDIR\php\php.exe"' '"$INSTDIR\php\myfile.php"'
-ExecShell open "$INSTDIR\apache\apache" "-i"
-ExecShell open "$INSTDIR\apache\apache" "-k start -n Apache"
these are working fine.

ExecShell open '"$INSTDIR\mysql\bin\mysql"' '"databasename < $INSTDIR\mysql\bin\myfile.sql"'
but this one doesnt work correctly. (tried with(out)'"). Its seeing the whole commandline as the databasename instead of the first part of the line.

im using a .bat file now but i would like to use execshell.
Any suggestions?

Regards,
Schultz#
I would suggest trying this

ExecShell open `"$INSTDIR\mysql\bin\mysql"` `'databasename < $INSTDIR\mysql\bin\myfile.sql'`
but now that i think about it that probably isn't much different then what you used. could you just use the Exec command like

Exec `"$INSTDIR\mysql\bin\mysql" "databasename < $INSTDIR\mysql\bin\myfile.sql"`
Darktrain#
well...i think ive tried all combinations. 😕

Do you know why the code is working for php en apache and not for mysql?

regards,
justin#
Use this:


Exec '"$INSTDIR\mysql\bin\mysql" "databasename" < $INSTDIR\mysql\bin\myfile.sql'

-Justin
Darktrain#
Hi Justin,

i tried your code. But its still seeing the whole commandline as the databasename instead of the first part of the line.

the .bat file im running looks like this:
  • cd mysql
  • cd bin
  • mysql databasename < "path\myfile.sql"


Maybe ive to go to the bin dir and then execute this?

Exec `"mysql" "databasename < $INSTDIR\mysql\bin\myfile.sql"`

//Darktrain
rainwater#
Originally posted by Darktrain
Hi Justin,

Maybe ive to go to the bin dir and then execute this?

Exec `"mysql" "databasename < $INSTDIR\mysql\bin\myfile.sql"`

You've still got the syntax wrong. You don't want quotes around the parameters. Mysql will think the whole string is the database name.

You sure you haven't tried:
Exec '"$INSTDIR\mysql\bin\mysql" "databasename" <"$INSTIDR\mysql\bin\myfile.sql"'
Darktrain#
yes, and it also isnt working.
Exec '"$INSTDIR\mysql\bin\mysql" "databasename"<"$INSTIDR\mysql\bin\myfile.sql"'
The last part of the commandline doesnt work with mysql(?).
kichik#
Hi!

This code:
Exec '"$SYSDIR\command.com" /c echo asdasd > asd.txt'
seems to work. If it works for > it should work for < too.

KiCHiK
petersa#
Hi DarkTrain,
ExpandEnvStrings $0 %COMSPEC%
Exec `"$0" /C "$INSTDIR\mysql\bin\mysql" "databasename" < "$INSTDIR\mysql\bin\myfile.sql"`
This piece of code should solve your problem. If it doesn't work, try modifying your myfile.sql file so that it loads databasename from it. Then, you would use:
ExpandEnvStrings $0 %COMSPEC%
Exec `"$0" /C "$INSTDIR\mysql\bin\mysql" < "$INSTDIR\mysql\bin\myfile.sql"`
You might prefer to use ExecWait.
  • DarkTrain stated that his command line worked with a batch file.
  • The command line contains '< filename', meaning 'use filename as the input device'.
This means that a command interpreter is required for it to work properly. I would have thought someone would pick that up. 😛