方法一:
#!/bin/bash
#ssh root@192.168.178.23ssh 192.168.178.23 << !
cd /root
bash test.sh
!
exit
方法二:
#!/bin/bash
#slave1 is the hostname or ip
ssh slave1 "cd /usr/;start-controller.sh;start-monitor.sh" &
本文介绍两种通过SSH远程执行脚本的方法。方法一利用bash脚本特性实现连续命令执行,包括改变目录及调用远程主机上的脚本。方法二则直接在单行内通过SSH发送并执行多个命令。
方法一:
#!/bin/bash
#ssh root@192.168.178.23exit
方法二:
#!/bin/bash
#slave1 is the hostname or ip
ssh slave1 "cd /usr/;start-controller.sh;start-monitor.sh" &
被折叠的 条评论
为什么被折叠?