【问题标题】:How do I pass command-line arguments to script executed from stdin如何将命令行参数传递给从标准输入执行的脚本
【发布时间】:2021-11-13 00:54:26
【问题描述】:

这些工作正常:

/bin/dash xyz.sh arg1
curl | /bin/dash -

用例:

curl | sh - arg1

Ubuntu 执行如下:

curl | /bin/dash - arg1

这失败了:sh: 0: Can't open arg1

如何将 arg1 传递给curl | /bin/dash

【问题讨论】:

    标签: dash-shell


    【解决方案1】:

    这是一个百灵鸟,通过例如localhost localhost 参数
    按要求发送至curl

    echo curl --head '"$@"' | sh -s localhost localhost
    

    【讨论】:

      猜你喜欢
      • 2013-10-11
      • 1970-01-01
      • 1970-01-01
      • 2013-07-05
      • 1970-01-01
      • 1970-01-01
      • 2014-03-08
      • 2013-10-22
      • 2016-12-19
      相关资源
      最近更新 更多