ssh [email protected]%s -o ConnectTimeout=2 "ssh [email protected]%s ConnectTimeout=2 "if [ ! -d /root/scripts ]; then mkdir /root/scripts; fi"" # 有语法错误
改变思路:(mkdir -p 参数)
ssh [email protected]%s -o ConnectTimeout=2 "ssh [email protected]%s ConnectTimeout=2 "mkdir -p /root/scripts"" # 先跳到跳板机上,然后再跳到目标机器上,看有没有 /root/scripts ,如果没有则创建