Old 11th February 2011, 15:59   #1
vjrabanelly
Junior Member
 
Join Date: Feb 2011
Posts: 7
Question 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 :
code:
sqlite3.exe WebData .dump > WebData.sql

which gives this syntax in NSIS :
code:
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 :
code:
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 )
code:
ExecDos::exec "sqlite3.exe WebData < WebData.sql" "" "log.txt"

> Output in log.txt :
Quote:
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
vjrabanelly is offline   Reply With Quote
Old 11th February 2011, 16:27   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Run it with cmd.exe (read COMSPEC to get its path).

Stu
Afrow UK is offline   Reply With Quote
Old 11th February 2011, 22:10   #3
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
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.
jpderuiter is offline   Reply With Quote
Old 14th February 2011, 07:59   #4
vjrabanelly
Junior Member
 
Join Date: Feb 2011
Posts: 7
Thumbs up

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) :
code:
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
vjrabanelly is offline   Reply With Quote
Old 14th February 2011, 10:23   #5
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
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.
pengyou is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
execdos, execwait, input, redirect

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