Thursday, September 20, 2012

curl order of show-error and silent options, and stderr redirect

Today I found that the order of curl parameters really makes a difference when you want to print error messages with set "show-error" and "silent" options. 


user@server:~/> curl --silent --show-error -k ""
curl: (6) Couldn't resolve host ''

user@server:~/> curl --show-error --silent -k ""


Another interesting observation - I have a script which does curl requests and captures the output. When I want to get error messages, I have to redirect error to stderr file first like this:

curl --silent --show-error -k "http://blablabla" 2>$OUTFILE.error | sed -e "...." >> $OUTFILE 

If I change the order to have error redirect at the end of command, it does not work (the error output is printed to console, but not to the file I requested):

curl --silent --show-error -k "http://blablabla" | sed -e "...." >> $OUTFILE 

No comments:

Post a Comment