Hi have a command which I am running using pexpect as follows,
options = '-q -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -
oPubkeyAuthentication=no'
timeout = 50
file = open('sshlog.txt', 'w')
ssh_cmd = 'ssh %s@%s %s' % (user, host, options)
child = pexpect.spawn(ssh_cmd, timeout=timeout,encoding='utf8')
child.logfile = file
child.expect(['[pP]assword: '])
child.sendline(password)
child.expect(".*#")
child.sendline("echo 'cmdstart'; cat <some command> ; echo $?; echo 'cmdend'")
child.expect('.*#')
cmdoutput = child.after
Here, my pexpect is timing out after 50 seconds as the command run is still not complete. However, the same command is getting completed in a few seconds when directly on the server.
Can someone help here ?