You are not logged in.
Pages: 1
Man I have been kitting my head against the desk trying to get this script to work. I need to embed a variable in a curl command that I'm passing via a bash script, and I'm having all sorts of trouble.
Here is the whole code so far:
#listen on port 9600 and put input into file
nc -v -l -p 9600 > input
#Get ***** SessionID
SESSION=$(curl -i -k -X POST -H 'Accept: application/xml' -d 'accessid=*****' -d 'password=*****' https://www.*****.com \
| egrep '<sessionid>.*</sessionid>' | sed -e 's/^[ \t]*//' -e 's/<sessionid>//' -e 's/<\/sessionid>//')
#assign variables
ACTION=`awk '{print $1}' < input`
SECONDS=`awk '{print $2}' < input`
DATE=`awk '{print $3}' < input`
WAVE=`awk '{print $4}' < input`
if [ "$ACTION" == "recall" ]; then
POST=$(curl -H 'Accept: application/xml' -H 'Content-Type: multipart/form-data; boundary=anteater' -X GET -b \'_session_id=$SESSIONID\' http://www.*****.com)
fiBash ends up executing this command:
curl -H 'Accept: application/xml' -H 'Content-Type: multipart/form-data; boundary=anteater' -X GET -b ''\''_session_id=64484c0c379529554757260d3806a9d8'\''' http://www.*****.comNote the wierd "\" that surrounds the session_id statement.
Do any of you know what I am doing wrong? Thanks for the help.
Offline
If
-b \'_session_id=$SESSIONID\'
translates to
-b ''\''_session_id=64...'\'''have you tried simpler things like
-b "_session_id=$SESSIONID"
or since there don't seem to be odd characters in $SESSIONID
-b _session_id=$SESSIONIDIf that last one works I think you were just adding an actual quote to the argument of -b.
Last edited by Procyon (2008-05-23 12:20:30)
Offline
Pages: 1