sneezry
V2EX  ›  问与答

shell 里如何拼接命令参数

  •  
  •   sneezry · Jun 14, 2015 · 3133 views
    This topic created in 4078 days ago, the information mentioned may be changed or developed.
    我想通过curl向服务器传送客户端的时间,然后是这么写的:

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

    然后参数中的$DATE被原样传给服务端了,并没有被替换成客户端的时间

    请问应该如何修改代码呢?
    2 replies    2015-06-14 22:51:32 +08:00
    slowman
        1
    slowman  
       Jun 14, 2015   ❤️ 1
    curl -X POST -d '{"time":"'"$DATE"'"}' http://xx.xx.xx.xx/xx/xx
    没试
    sneezry
        2
    sneezry  
    OP
       Jun 14, 2015
    @1423 成功了,感谢!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1250 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:47 · PVG 07:47 · LAX 16:47 · JFK 19:47
    ♥ Do have faith in what you're doing.