【问题标题】:Curl not performing the action卷曲不执行动作
【发布时间】:2013-10-01 13:24:12
【问题描述】:

我使用 curl 来执行 get 操作。 (此链接将发出服务器重启)

curl -v -u username:password http://example.com/index.html?process=waterServer&action=restart 

似乎 curl 忽略了请求中的操作部分。我得到输出,

*   Trying example.com... connected
* Server auth using Basic with user 'username'
> GET /index.html?process=waterServer HTTP/1.1
> Authorization: Basic #############
> User-Agent: bla bla bla
> Host: example.com
> Accept: */*

然后输出HTML页面并以行结束

[1]+ 完成 curl -v -u 用户名:密码http://example.com/index.html?process=waterServer

这是正确的行为吗?如果上面的链接是复制粘贴在浏览器上,它会询问用户名/密码并重新启动服务器。

【问题讨论】:

    标签: curl


    【解决方案1】:

    您必须在 URL 参数中转义您的“&”。

    curl -v -u 用户名:密码http://example.com/index.html?process=waterServer^&action=restart

    如果这不起作用,请尝试使用 curl --data-urlencode

    【讨论】:

    • 它没有用。我得到相同的输出> GET /index.html?process=waterServer^ HTTP/1.1 >. 最后一行是相同的[1]+ Done curl -v -L -u username:password http://example.com/index.html?process=waterServer^
    • 嗯,转义取决于您使用的操作系统。
    • 刚刚添加了另一种方式
    • 那也行不通。感谢您指出转义&。我已经添加了答案。
    【解决方案2】:

    在 Ubuntu 上工作的正确选项是 -d。现在要执行的命令是,

    curl -L -u username:password http://example.com/index.html? -d process=waterServer -d action=restart 
    

    -L 是获取重定向页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-08
      • 2023-03-19
      • 1970-01-01
      • 2018-06-07
      • 2018-06-05
      • 2017-03-27
      相关资源
      最近更新 更多