gpt4 book ai didi

linux - 如何通过屏幕中的远程机器启动 nc

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:55:31 25 4
gpt4 key购买 nike

我需要在屏幕上的远程机器上启动 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'

虽然从部署机器运行时上述两个命令不起作用。有人可以帮我提供更好的方法吗。

提前致谢 =)

最佳答案

你可以有更好的解决方案,比如

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

关于linux - 如何通过屏幕中的远程机器启动 nc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26435328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com