提问人:Ben 提问时间:5/17/2019 更新时间:5/17/2019 访问量:1372
在脚本中使用子 shell 命令时,SSH EOF 不返回任何内容 [duplicate]
SSH EOF returns nothing when using subshell commands in a script [duplicate]
问:
我正在尝试通过 SSH 运行一系列命令。这个答案启发了我使用 EOF,起初它似乎工作正常,但一旦我尝试使用 $() 运行子 shell 命令,它就开始起作用了。
任何人都明白为什么会这样:
#!/bin/bash
ssh -o StrictHostKeyChecking=no -tt [email protected] << EOF
cd "$(ls -td -- ~/www/builds/* | head -n 1)"
pwd
composer install
npm run installation
npm run clean
npm run build
exit
EOF
这是吗?
17-May-2019 10:29:26 Last login: Fri May 17 12:28:44 2019 from 82.148.198.138
17-May-2019 10:29:26
17-May-2019 10:29:26 cd ""
17-May-2019 10:29:26 pwd
17-May-2019 10:29:26 composer install
17-May-2019 10:29:26 npm run installation
17-May-2019 10:29:26 npm run clean
17-May-2019 10:29:26 npm run build
17-May-2019 10:29:26 exit
从 shell 脚本执行时,子 shell 返回空白,但在 bash 终端中手动执行它时工作正常。这也发生在没有双引号的情况下。
我在 Ubuntu 服务器上执行此操作。
答: 暂无答案
评论
<< EOF
<< 'EOF'