Skip to content
⌘ NSIS Forum Archive

Trying to return data from CURL.exe using ExecDos::exec

3 posts

winterspan#

Trying to return data from CURL.exe using ExecDos::exec

I have tried to use ExecDos::Exec to call cURL.exe from NSIS and receive the output from the webserver. however, despite trying many different things, (including options for ExecDos like /TOSTACK, and command line options for CURL) I can't get the actual CURL output (the HTML returned from the webserver) back into NSIS.

After I call:
ExecDos::exec "curl" "http://mywebservice.com/path/
Pop $connectResult

$ConnectResult just contains an integer that represents the return code of the process. How do I get ConnectResult to contain the actual data returned from the webservice call?
winterspan#
Answering my own question... What you have to do is first pop the returncode off the stack, then the stack will contain the web response, e.g.:

ExecDos::exec /TOSTACK "curl http://website.com/servicecall?param=value -s"
Pop $responsecode
Pop $responsebody
Afrow UK#
You should add two empty arguments to the end (for stdin_string and log_file_name) otherwise, if the stack is not empty, you can have some unexpected results which may drive you mad in future.

Edit: Also make sure you give a full quoted path to curl.exe. Relative paths are never a good idea.

Stu