I want to use an expect or Pexpect file to automate a shell command like:
for host in HostList:
ssh -t kitty@host 'sudo nohup bash -c "./tcp_sender > /dev/null 2>&1 &"'
if I manually input the command, there are 3 possibilities
for case 2, I have to input a yes
, for the other cases I don't need to input anything
password is not needed.
1)
[kitty@goeland kitty]$ ssh -t kitty@202.171.61.205 'sudo nohup bash -c "./tcp_sender > /dev/null 2>&1 &"'
nohup: ignoring input and appending output to `nohup.out'
Connection to 202.171.61.205 closed.
2)
[kitty@goeland kitty]$ ssh -t kitty@202.171.61.205 'sudo nohup bash -c "./tcp_sender > /dev/null 2>&1 &"'
The authenticity of host '202.171.61.205 (202.171.61.205)' can't be established.
RSA key fingerprint is ff:0b:9c:a9:72:52:8f:53:0d:04:d5:ea:d9:3c:56:37.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '202.171.61.205' (RSA) to the list of known hosts.
nohup: ignoring input and appending output to `nohup.out'
Connection to 202.171.61.205 closed.
3) different errors, at the moment I haven't got yet
for 3, I want to know the errors
so how to use expect
or Pexpect
to do this?
preferably Pexpect
thanks!