【发布时间】:2020-09-21 10:45:05
【问题描述】:
我正在尝试从另一个脚本 (test.sh) 运行一个脚本(用于安装和设置 Postgres DB)。问题是在我的脚本中调用的脚本是远程的(在 GitHub 上在线)并且它不起作用。
我尝试以三种不同的方式调用脚本。
- 本地 - 工作
- 远程使用
bash <(curl...- 引发错误 - 远程使用
curl ... | bash -s- 下载脚本并挂起...
test.sh
#!/bin/bash
# this works correctly (it's the same but local)
sudo bash postgres/setup.sh
# this raises "bash: /dev/fd/63: No such file or directory"
sudo bash <(curl -s https://raw.githubusercontent.com/milano-slesarik/sh-ubuntu-instant/master/postgres/setup.sh)
# this hangs
curl https://raw.githubusercontent.com/milano-slesarik/sh-ubuntu-instant/master/postgres/setup.sh | sudo bash -s
最后一个可能会下载脚本但随后挂起...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1532 100 1532 0 0 8281 0 --:--:-- --:--:-- --:--:-- 8281
你知道如何让它工作吗? 我希望我的脚本在线,这样我就不必一直克隆/下载。
【问题讨论】:
-
不应该像这样运行从远程服务器通过管道传输的脚本的原因:security.stackexchange.com/q/213401/215097
-
@LéaGris 我明白,但这是我的存储库,所以我认为它很安全,因为没有人可以修改代码。
标签: bash shell ubuntu scripting