【问题标题】:Linux script with curl to check webservice status带有 curl 的 Linux 脚本来检查 Web 服务状态
【发布时间】:2015-02-25 13:41:05
【问题描述】:

我在http://localhost/testing/validateLicence 提供了一个许可证验证网络服务

我想编写一个 shell 脚本,我必须通过 webservice call 传递许可证密钥。如果 webservice 返回 200 OK,则执行 shell 脚本中的进一步步骤,否则将终止执行

请根据我的要求帮助我调用 Web 服务并比较 if/else 块中的 http 响应代码

【问题讨论】:

  • 恕我直言,您的许可证检查需要验证身份。

标签: web-services shell unix curl wget


【解决方案1】:

看看这个问题:

https://superuser.com/questions/272265/getting-curl-to-output-http-status-code

您应该可以在脚本中为您的逻辑使用类似的内容(从那里的第二个答案):

curl -s -o /dev/null -I -w "%{http_code}" http://www.example.org/

如果您的网络服务不喜欢 HEAD 请求,请删除 -I。

【讨论】:

    猜你喜欢
    • 2012-09-26
    • 1970-01-01
    • 2017-03-03
    • 1970-01-01
    • 2016-08-31
    • 1970-01-01
    • 1970-01-01
    • 2012-04-27
    • 2021-11-11
    相关资源
    最近更新 更多