Hai Friends
This is my first post to this forum. I am new to Python but I find its quite interesting. I have a problem with the folowing code...
##########################
import telnetlib
import sys
HOST = "192.168.10.5"
USER = "somename"
PASSWORD = "somepassword"
telnet = telnetlib.Telnet(HOST)
telnet.read_until("login: ")
telnet.write(USER + "\n")
telnet.read_until("Password: ")
telnet.write(PASSWORD + "\n")
telnet.write("top -p 1 -n 1\n")
telnet.write("exit\n")
some_value = telnet.read_all()
print some_value
#############################
The problem is that, when I print 'some_value' I get
" top: Unknown terminal "network" in $TERM ". But when I use other commands like 'ls -l' or 'df -h' it works fine & gives me the o/p of the commands. I tried by redirecting the o/p to a file like "top -p 1 -n 1 >> test\n" & then reading the contents of the file, but still it doent work. The file created thru Python was empty. When I directly work on Linux, the command works fine. Can anybody tell what the problem is...