简体   繁体   English

Shell 脚本 - SSH 使用屏幕

[英]Shell Script - SSH using Screen

I am trying to develop a shell script / bash script with ssh and screen, using Ubuntu / Linux. I am trying to develop a shell script / bash script with ssh and screen, using Ubuntu / Linux. Could you help me to correct what is wrong here?你能帮我纠正这里的问题吗?

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

It doesn't work.它不起作用。

You fell victim to shell quoting - which is tricky when using ssh.您成为 shell 引用的受害者 - 这在使用 ssh 时很棘手。 Your command does something alike你的命令做了类似的事情

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

so I would try所以我会尝试

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM