neil.benn
1st November 2006 23:22 UTC
nsExec::execToStack w/ spaces
Hello,
I am using nsExec::execToStack to call a program I have written,I am passing it:
48#"\windows\CrEme\bin\CrEme.exe" -Of -vkb -wd '|PROGRAM_FILES|\DropPaq' -jar 'bin\DropPaq.jar' etc\RippleConfig.xml fire default
as a parameter. the program then returns:
48#"\windows\CrEme\bin\CrEme.exe" -Of -vkb -wd 'Programme\DropPaq' -jar 'bin\DropPaq.jar' etc\RippleConfig.xml fire default
basically, it interrrogates a PDA to find out the names of the special directories and returns the result from the string to stdout. When I'm popping the result off the stack I only get the text up to the space :
48#"\windows\CrEme\bin\CrEme.exe"
I'mnot sure if it is the quotes or the space that is giving me the problem, I've tried popping the data off twice to see if I get the next bit but nothing is happening. Has anyone ever seen this effect? If so do you know what is going on and do you know how to circumvent it?
Thanks for your help.
Cheers,
Neil
kichik
2nd November 2006 08:40 UTC
Works fine for me with invalid input. It just pushes "error" on the stack. What's the exact code you're using?
neil.benn
2nd November 2006 20:08 UTC
Hello,
Thanks for the response, the program gives the base response works as seen above when run from the command prompt. The NSIS code that calls this is as follows:
---
DetailPrint "Accessing PDA"
nsExec::Exec '$INSTDIR\CEFileOp.exe /c dev:"|PROGRAMS|\DropPaq Fire.lnk" desk:"DropPaq Fire.lnk"'
call CheckCESuccess
IfErrors FailedMod
DetailPrint "Checking system"
FileOpen $3 "DropPaq Fire.lnk" r
FileRead $3 $4
FileClose $3
MessageBox MB_OK '"$INSTDIR\CEFileOp.exe" /r $4'
nsExec::ExecToStack '"$INSTDIR\CEFileOp.exe" /r $4'
call CheckCESuccess
Pop $0
MessageBox MB_OK $0
Pop $1
MessageBox MB_OK $1
IfErrors FailedMod SuccessMod
FailedMod:
SetErrors
Return
SuccessMod:
DetailPrint "Successful Access"
---
Basically this connects to the handheld, retrieves the file 'Droppaq Fire.lnk', reads th contents out nto a string and then calls the replace on that string. I have checked that the file is being read correctly as the correct data shows up on the messagebox, this calls the exe with the details as used on the command line. However the return via nsExec::ExecToStack only shows the following bit, however this is missing the quotes I actually get returned -
48#\windows\CrEme\bin\CrEme.exe
Note, this is without the quotes, so I assume that the quotes in the return string are causing me a problem. In addition,when I pop off the stack twice, the second time gives me an error so there is no more to retrieve from stdout.
I'm going to try making a batch file which returns a string with quotes in to see what that does when called with nsExec:ExecToStack.
However,if anyone has seen this before - tips would be great :).
Cheers,
Neil
kichik
2nd November 2006 20:27 UTC
What about the code for CheckCESuccess? Does it not touch the stack at all?
Make sure you're not passing new line characters along with $4 after you FileRead it. Use TrimNewLines to remove them.
neil.benn
8th November 2006 13:08 UTC
Hello,
Apologies, the error was with my code - I had rogue speechmarks in the execution string that I was not escaping - I escaped them and it now works fine.
Cheers,
Neil