执行存储在通过SSH文件Bash脚本 [英] Execute Bash script stored in a file over SSH
本文介绍了执行存储在通过SSH文件Bash脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说我已经存储在文件中下面的Bash脚本 foo.sh
:
#!/斌/庆典
回声富
而不必 SCP
文件,我怎么能执行存储在 foo.sh
脚本中的遥控器上机器?
我曾尝试以下(有一些变化)没有成功的:
$ SSH根@远程的eval`猫foo.sh`
的eval`猫foo.sh`
似乎扩大到评估#!/斌/ bash的回声富
点击这里
解决方案
SSH根@ machineB上'庆典-s'< local_script.sh
我是从那个线程:<一href=\"http://stackoverflow.com/questions/305035/how-to-use-ssh-to-run-shell-script-on-a-remote-machine\">how使用ssh在远程机器上运行shell脚本?
Say I have the following Bash script stored in the file foo.sh
:
#!/bin/bash
echo foo
Without having to scp
the file, how could I execute the script stored in foo.sh
on a remote machine?
I have tried the following (with a few variations) to no success:
$ ssh root@remote eval `cat foo.sh`
eval `cat foo.sh`
seems to expand to eval #!/bin/bash echo foo
here
解决方案
ssh root@MachineB 'bash -s' < local_script.sh
I got it from that thread: how to use ssh to run shell script on a remote machine?
这篇关于执行存储在通过SSH文件Bash脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文