Skip to content
⌘ NSIS Forum Archive

ExecDos : redirect input data

5 posts

vjrabanelly#

ExecDos : redirect input data

Hi,

I'm looking for a way to handle input data redirection in ExecDos::exec.
Thanks to some threads in the forum, I already found a way to redirect output.
I wanted to do this in DOS :
sqlite3.exe WebData .dump > WebData.sql
which gives this syntax in NSIS :
ExecDos::exec "sqlite3.exe WebData .dump" "" "WebData.sql"
Well... great!

But now I need to do it the opposite way, which would be, in DOS :
sqlite3.exe WebData < WebData.sql
I tried a lot of different syntaxes until now with ExecDos::exec and ExecWait but couldn't make it work...
I tried this, among other things (this attempt looked the most promissing one 🙄)
ExecDos::exec "sqlite3.exe WebData < WebData.sql" "" "log.txt"
> Output in log.txt :
sqlite.exe: Error: Too many options: "WebData.sql"
(But it works perfectly when I do it in command line directly, so the problem is not with sqlite3.exe, it's with the way arguments are passed to the function by ExecDos...)

Any idea how I could do this? Is something like this possible?

Thank you

Valentin
jpderuiter#
The second parameter is the stdin.
You'll have to read the content of the file WebData.sql into a variable, and set that variable as the second parameter.
But the length of an NSIS string is limited, so maybe the best way would be the one suggested by Stu.
vjrabanelly#
Thanks to your answers and to the post here, I got it to work! Thank you!

So here are my lines now, using ExecCmd (as I understood that ExecCmd already includes the call to cmd.exe with COMSPEC) :
ExecCmd::exec '"$PLUGINSDIR\sqlite3.exe" $PLUGINSDIR\WebData .dump > $PLUGINSDIR\WebData.sql' ""
ExecCmd::exec '"$PLUGINSDIR\sqlite3.exe" $PLUGINSDIR\WebData < $PLUGINSDIR\WebData.sql' ""
It works great this way, but if I put quotes around $PLUGINSDIR\WebData and/or around $PLUGINSDIR\newSql.sql, it fails... Any idea why? I'm afraid it'd fail if $PLUGINSDIR has a space in its name on the machine it gets installed... is there a risk?

Thank you!

Valentin
pengyou#
I use nsExec::Exec and %COMSPEC% to run sqlite3.exe and I have no trouble using quotes around the input and output files for the .dump command.