0
我使用Cygwin來運行我的CURL命令。爲什麼從命令行curl成功,但在此腳本中失敗?
$ 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."}
正如你所看到的那樣,工作正常並且很好地上傳到遠程服務器。我試圖通過將其放入腳本文件來自動化這個專業。
我的腳本文件:
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];
錯誤:
$ /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
對不起,我不退出按照你的建議。我應該把我的第一行作爲... cd/cygdrive/x'?和.... [email protected]''??? – nkman 2013-04-11 20:37:55
這是你傳遞給'-H'選項的參數。它有一個單引號字符來打開它(「Content-type ...」),但是最後你錯過了最後一個。 – Costa 2013-04-11 21:10:45
謝謝。就是這樣! .. – nkman 2013-04-12 13:44:55