telnet - Telnetlib python write() not working as expected -


i trying automate set of telnet commands used when configuring linux server. trying use python 2.7 , thought telnetlib way go. unfortunatly doesn't work expect.

tn = telnetlib.telnet(ip, port) print tn.read_until("syscli>") tn.write("help" +"\n") print tn.read_until("registered components are:", 10) 

this terminate after 10 seconds printing nothing first print line: "syscli>". have tried different combinations of "carriage return" , "line feed" including "\r", "\r\n", "\n\r", none of them seem help. have suggestion on missing?

update: tried code on different server , seems work fine:

ip = "www.google.com" port = 80  tn = telnetlib.telnet(ip, port) tn.write("get / http/1.1" +"\n" +"\n")  print tn.read_some() 

so thinking problem server needs special character sending messages.

so apparently had misunderstood system bit. after initial connection no longer telnet session per se application running on server. reason see syscli prompt. why can't use telnetlib.

instead try use subprocecss.popen() run session through terminal.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -