【问题标题】:use parameter in curl command在 curl 命令中使用参数
【发布时间】:2023-02-11 20:45:37
【问题描述】:

我有一个容器参数,我想在运行 curl 命令期间使用此参数。我像下面这样使用,但它给出了一个错误。对此有什么想法吗?我在 bash 脚本中使用它。

curl -X 'GET' 'https://mycontainer/api/v2.0/projects/testproject/repositories/$(container)/artifacts?page=1&page_size=1&with_tag=true&with_label=false&with_scan_overview=false&with_signature=false&with_immutable_status=false&with_accessory=false' -H 'accept: application/json' -H 'X-Accept-Vulnerabilities: application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' -H 'authorization: Basic YWhtZXQuY2Fua2F5YUBucy5ubDo2MkVEbDIxUEM=' | jq '.[].tags[].name' > output2.txt

【问题讨论】:

    标签: bash curl


    【解决方案1】:

    使用 " 而不是 '。 对于变量替换,使用${}

    该命令将是:

    curl -X 'GET' "https://mycontainer/api/v2.0/projects/testproject/repositories/${container}/artifacts?page=1&page_size=1&with_tag=true&with_label=false&with_scan_overview=false&with_signature=false&with_immutable_status=false&with_accessory=false" -H 'accept: application/json' -H 'X-Accept-Vulnerabilities: application/vnd.security.vulnerability.report; version=1.1, application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0' -H 'authorization: Basic YWhtZXQuY2Fua2F5YUBucy5ubDo2MkVEbDIxUEM=' | jq '.[].tags[].name' > output2.txt
    
    

    【讨论】:

      猜你喜欢
      • 2012-11-02
      • 2012-07-11
      • 2020-09-08
      • 2014-07-26
      • 2014-05-18
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      • 2014-08-03
      相关资源
      最近更新 更多