shell curl 拼接參數問題


1   shell環境中

DATE=$(date +"%Y-%m-%d %H:%M:%S")
curl -X POST -d '{"time":"$DATE"}' http://xx.xx.xx.xx/xx/xx

這樣請求會把$DATE當成參數值。調整的方式是

curl -X POST -d '{"time":"'"$DATE"'"}' http://xx.xx.xx.xx/xx/xx

這樣就可以了!

2 shell case in用法

case "$1" in 

init)
init
;;
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
*)
echo "Usage: $0 {init|start|stop|restart|reload}"
exit 1
;;
esac

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM