Search code examples
curlcygwin

Why does curl succeed from the command line but fail in this script?


i use Cygwin to run my CURL command.

$ curl http://URL/update.json --connect-timeout 10000 --max-time 10000 --data-binary @bars.json -H 'Content-type:application/json;charset=utf-8;[email protected];'
{"uploaded":true,"message":"Bars JSON received.  A email will be sent after processing has completed."}

as you can see, that works fine and uploaded fine to the remote server. I'm trying to automate this profess by putting this into script file.

my script file:

cd /cygdrive/x
curl http://URL/update.json --connect-timeout 10000 --max-time 10000 --data-binary @bars.json -H 'Content-type:application/json;charset=utf-8;[email protected];

error:

$ /bin/test.sh
: No such file or directorycygdrive/x
/bin/test.sh: line 2: unexpected EOF while looking for matching `''
/bin/test.sh: line 3: syntax error: unexpected end of file

Solution

  • You need to add a closing ' to the end of the command.

    curl http://URL/update.json --connect-timeout 10000 --max-time 10000 \
     --data-binary @bars.json \
     -H 'Content-type:application/json;charset=utf-8;[email protected]'