我有一个很长的字符串 ssh_cmd,我从
cmd = """kill -9 `ps -ef|grep "udp_receiver"|grep -v "grep"|awk '{print $2}'`"""
HostName="133.33.22.1"
ssh_cmd = """ssh -t inria_spoofing@{0} 'sudo nohup bash -c "{1} > /nohup.out 2>&1 &"'""".format(HostName, cmd)
结果ssh_cmd
是:
ssh -t kitty@133.33.22.1 'sudo nohup bash -c "kill -9 `ps -ef|grep "udp_receiver"|grep -v "grep"|awk '{print $2}'` > /nohup.out 2>&1 &"'
但是,我害怕当我跑步时
child = pexpect.spawn(ssh_cmd)
有问题,那么如何组织字符串呢?谢谢!