前言

有时候shell脚本可以放在http页面上,不用download,可以直接执行。

通常我们可以用curl的方式执行http页面上的shell脚本。 一般方式是:

curl http://XXX.com/xx/xx.sh | bash

无名参

-s方式

curl -s http://XXX.com/xx/xx.sh | bash -s arg1 arg2

bash <

bash <(curl -s http://XXX.com/xx/xx.sh) arg1 arg2

具名参

由于直接调用了bash命令,因此在远程脚本需要传递具名参数时,为了区分是bash命令的参数还是远程脚本的,可以使用--作为区分,可以理解为分割线,--前面的比如-s属于bash,后面的-x abc -y xyz属于远程脚本的参数

curl -L http://XXX.com/xx/xx.sh | bash -s -- -x abc -y xyz