0
我想要傳遞一個主機名以從Java樣式屬性文件中捲曲。由sed返回的字符串無法使用curl
this.properties
instance.dns=localhost
...
bash命令
./postFiles.sh this.properties
bash腳本
#!/bin/bash
#blows up
HOST=$(grep "^instance.dns=" ${1}| sed "s%instance.dns=\(.*\)%\1%")
URL="$(echo 'http://admin:[email protected]'${HOST}':8080/documentservice/api/doc')"
echo "$URL"
#works
HOST="$(echo 'localhost')"
URL="$(echo 'http://admin:[email protected]'${HOST}':8080/documentservice/api/doc')"
echo "$URL"
curl -v --globoff -F 'docKey=testFile0' -F 'fileType=IFP Paper Application' -F '[email protected]' $URL
兩個代碼塊呼應相同的URL:
http://admin:[email protected]:8080/documentservice/api/doc
但是,如果我用SED捲曲產生的網址無法解析主機
Adding handle: conn: 0x7ff473803a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7ff473803a00) send_pipe: 1, recv_pipe: 0
* Could not resolve host: localhost
* Closing connection 0
curl: (6) Could not resolve host: localhost
爲什麼sed的鏈接不可用,它看起來什麼時候一樣?
底線字符一定是這個問題,謝謝! – jeremyjjbrown