On 11/08/2012 10:48 PM, T. Girowall wrote: The quoting levels in this message are probably messed up, but I fixed the order, and tried to fix the levels.
>> On 11/08/2012 09:33 PM, T. Girowall wrote: >>> <snip> >>> ip: 192.168.xx.xx >>> port: 2332 >>> >>> Any help is appreciated, >>> Tim >>> import getpass import sys import telnetlib HOST = "localhost" user = raw_input("Enter your remote account: ") password = getpass.getpass() tn = telnetlib.Telnet(HOST) tn.read_until("login: ") tn.write(user + "\n") if password: tn.read_until("Password: ") tn.write(password + "\n") tn.write("ls\n") tn.write("exit\n") print tn.read_all() >>> >>> > Dave Angel <d...@davea.name> wrote: >> >> This is a text mailing list; your html mail thoroughly mangles your >> code for the majority of readers. >> >> Is there a reason why you used 192.168.xx.xx with putty, but used >> localhost with your python code? >> > David, > > I'm new to this stuff so I apologize if dum mistakes are made. > > The device I'm connecting to has the 192.168 IP address and that's I should'v > used in the code example. I did try changing the HOST = "192.168.xx.xx" but > still got the same error message. I noticed that the default Port in Putty > for Telnet is 23 but my device's port is 2332. Could this be the problem? If > so, how I can change the port number? > > Here is the code in Text: > > import getpass > import sys > import telnetlib > > def main(): > pass > > HOST = "192.168.xx.xx" > user = raw_input("Enter your remote account: ") > password = getpass.getpass() > > tn = telnetlib.Telnet(HOST) > > tn.read_until("login: ") > tn.write(user + "\n") > if password: > tn.read_until("Password: ") > tn.write(password + "\n") > > tn.write("ls\n") > tn.write("exit\n") > > print tn.read_all() > > if __name__ == '__main__': > main() > > Where's the error message, including the traceback? Somebody (not me) who is familiar with telnetlib can presumably help, given enough information. -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor