【问题标题】:Shell Script - SSH using ScreenShell 脚本 - 使用 Screen 的 SSH
【发布时间】:2021-05-19 10:07:44
【问题描述】:

我正在尝试使用 Ubuntu/Linux 开发带有 ssh 和屏幕的 shell 脚本/bash 脚本。 您能帮我纠正这里的问题吗?

#!/bin/bash
ssh -i keypair.pem -t ubuntu@ec2-address "screen -S teste"; cd 'home'; cd 'Shell'; ./'AWS - teste.sh' "

它不起作用。

【问题讨论】:

    标签: bash shell amazon-ec2 ssh gnu-screen


    【解决方案1】:

    您成为了 shell 引用的受害者——这在使用 ssh 时很棘手。你的命令做了类似的事情

    cd home/Shell; ./AWS - teste.sh
    

    所以我会尝试

    ssh -i keypair.pem -t ubuntu@ec2-address screen -S teste "sh -c \"cd home/Shell; ./AWS - teste.sh\""
    

    【讨论】:

      猜你喜欢
      • 2018-07-16
      • 1970-01-01
      • 1970-01-01
      • 2010-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多