0

telnetlib is helping me to connect to remote host and do the user login.
but, when i try doing the super user login, it hangs

...............
..............
...............
User="abc"
Password="abc"
Superuser_id="yyy"
su_passwd="xxx"

#-- establish a telnet connection to all the remote hosts in the list except the host running script
telnet=telnetlib.Telnet(Host)
telnet.read_until("login:")
telnet.write(User+'\r\n')
telnet.read_until("Password:")
telnet.write(Password+'\r\n')
time.sleep(5)
print telnet.read_until('[abc@xyz abc]$ ')
telnet.write(Superuser_id+'\r\n')
print telnet.read_until("Password:")
telnet.write(su_passwd+'\r\n')
time.sleep(5)
print telnet.read_until('[root@xyz abc]#')
telnet.write("cd /folder1/folder2/%s\n"%version)
.............
...........
...........
any idea why it hangs and doesnt do a cd:?
it works fine when i don't try to do a super user login.

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Simplified
0

can you please paste your code again in the code tags .;) we need this...

Edited by richieking: n/a

0

Have you tried these commands manually? Perhaps there is a pause, so you could try adding in the following:

import time

# your code...

time.sleep(5)

The above will pause for 5 seconds. I've found this is a problem sometimes with telnet...

Post your source code (as richieking says...) and we can help more :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.