【问题标题】:Bash, pipe output to command and get error codeBash,管道输出到命令并获取错误代码
【发布时间】:2012-03-15 14:45:32
【问题描述】:

我正在尝试使用带有 curl 的肥皂调用来获取 xml,请参见下文。如您所见,我将 echo 命令的输出通过管道传输到 curl 的 -d 参数中。我们有一个旧版本的 curl,因此我们不能使用 --data-urlencode 函数。现在我的解决方案有效,但是我不知道如何获取 curl 命令的错误代码。请帮忙!

$HEADER="<xml>this is my header I want to post</xml>"
echo $HEADER | curl -H 'Content-Type: text/xml; charset=utf-8' -H 'SOAPAction:https://blabla' -d @- -o output.xml -X POST https://blablabla

【问题讨论】:

    标签: pipe ksh


    【解决方案1】:

    可以通过变量'$?'获取bash中上一条命令的错误码

    【讨论】:

      猜你喜欢
      • 2012-02-08
      • 2015-12-07
      • 1970-01-01
      • 2021-05-20
      • 2012-02-29
      • 1970-01-01
      • 2014-06-07
      • 1970-01-01
      • 2016-10-10
      相关资源
      最近更新 更多