我需要在屏幕上的远程计算机上启动nc并从屏幕上的另一台远程计算机开始传输文件,我试图通过使用bash脚本的部署机器(jenkins)来运行它
远程机器1上的,即tester1:
ssh -tt mysql@tester1 'screen -d -m nc -l -w 60 5555 | tar xvif -'
在远程机器2上,即tester2:
ssh -tt tester2 'screen -d -m sudo -u mysql innobackupex --stream=tar --databases="sampledb" /mysql-backup/prodfullbkp | nc -w 30 tester 5555'
虽然上述两个命令在部署机器上运行时无效。但有人可以帮我提供更好的方法。
提前致谢=)
答案 0 :(得分:1)
您可以拥有更好的解决方案,例如
ssh user@host << EOF
#command to excecute
EOF
即tester1将是
ssh -tt mysql@tester1 << EOF
screen -d -m nc -l -w 60 5555 | tar xvif -
EOF
tester2将是
ssh -tt tester2 << EOF
screen -d -m sudo -u mysql innobackupex --stream=tar --databases="sampledb" /mysql-backup/prodfullbkp | nc -w 30 tester 5555
EOF