json 요청을 보내고 게시 데이터에 변수를 포함시키고 싶습니다. 약간의 연구를했고 변수 주위에 작은 따옴표를 사용했습니다.Bash 스크립트 : 말풍선에 문자열 변수 사용 JSON 게시 데이터
#!/bin/bash
FILENAME="/media/file.avi"
curl -i -X POST -H "Content-Type: application/json" —d '{"jsonrpc": "2.0", "method": "Player.Open", "params":{"item":{"file":"'$FILENAME'"}}}' http://192.167.0.13/jsonrpc
불행하게도 나는 약간의 오차가 얻을 :
curl: (6) Couldn't resolve host '—d'
curl: (3) [globbing] nested braces not supported at pos 54
HTTP/1.1 200 OK
Content-Length: 76
Content-Type: application/json
Date: Wed, 29 Jan 2014 19:16:56 GMT
{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
이 Appearently 괄호하고 HTTP 응답 상태 몇 가지 문제가 있습니다, 명령이 실행되지 않을 수 있음. 내 코드가 뭐가 잘못 됐어? 감사합니다.
이 내 curl
버전 :
curl 7.30.0 (mips-unknown-linux-gnu) libcurl/7.30.0 OpenSSL/0.9.8y
Protocols: file ftp ftps http https imap imaps pop3 pop3s rtsp smtp smtps tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL
이 가능성이 높은 후보'컬처럼 보인다 :
다음은 디지털 오션에 CoreOS 방울을 만드는 데 사용되는 JSON 데이터를 요청할 준비하는 예입니다 (6) '호스트를 확인할 수 없습니다 - 디부. '남자 컬 (man curl) '을하고'--data'를 찾는다. 행운을 빕니다. – shellter
'd' 옵션 앞의 문자는 특별한 타이포그래피 대시처럼 보이십니까? – halfbit
@ 할 빗 : 잘 잡으세요! (좋은 이름입니다!) – shellter