<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hi all,</FONT></DIV>
<DIV><FONT size=2>I'm really new to Python programming, only been tinkering with 
it a couple of days. I started writing this program and can't quite work out 
what I'm doing wrong. I want the user to enter the details in the dialog box and 
then when they hit execute it runs the telnet stuff and writes the output back 
to a file. I'm obviously doing something really stupid and need some 
help.</FONT></DIV>
<DIV><FONT size=2>Any pointers would be great.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Cheers</FONT></DIV>
<DIV><FONT size=2>Lee</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>My code :</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2><EM>import telnetlib<BR>import sys<BR>import 
Tkinter</EM></FONT></DIV>
<DIV><FONT size=2><EM></EM></FONT> </DIV>
<DIV><FONT size=2><EM>from Tkinter import *</EM></FONT></DIV>
<DIV><FONT size=2><EM></EM></FONT> </DIV>
<DIV><FONT size=2><EM>def detail() :<BR>    telnet = 
telnetlib.Telnet(HOST)<BR>    telnet.read_until("login: 
")<BR>    telnet.write(USER + "\n")<BR>    
telnet.read_until("Password: ")<BR>    telnet.write(PASSWORD + 
"\n")<BR>    telnet.write("ls -l 
/etc/init.d/oracle.sh\n")<BR>    telnet.write("ls -l 
/etc/rc3.d|grep orac\n")<BR>    telnet.write("cat 
/etc/oratab\n")<BR>    
telnet.write("exit\n")<BR>    info = 
telnet.read_all()<BR>    file = open('c:/temp/listing.txt', 
'w')     #write info to file<BR>    
file.writelines(info)<BR>    file.close()</EM></FONT></DIV>
<DIV><FONT size=2><EM></EM></FONT> </DIV>
<DIV><FONT size=2><EM>login = Tk()</EM></FONT></DIV>
<DIV><FONT size=2><EM></EM></FONT> </DIV>
<DIV><FONT size=2><EM>Label(login, text="User Name:").grid(row=0, 
sticky=W)<BR>Label(login, text="Password:").grid(row=1, 
sticky=W)<BR>Label(login, text="Host:").grid(row=2, sticky=W)</EM></FONT></DIV>
<DIV><FONT size=2><EM></EM></FONT> </DIV>
<DIV><FONT size=2><EM>entry_ln = Entry(login)<BR>entry_fn = 
Entry(login)<BR>entry_ph = Entry(login)</EM></FONT></DIV>
<DIV><FONT size=2><EM></EM></FONT> </DIV>
<DIV><FONT size=2><EM>USER = entry_ln.grid(row=0, column=1)<BR>PASSWORD = 
entry_fn.grid(row=1, column=1)<BR>HOST = entry_ph.grid(row=2, 
column=1)</EM></FONT></DIV>
<DIV><FONT size=2><EM></EM></FONT> </DIV>
<DIV><FONT size=2><EM>b_execute = Button(login)<BR>b_execute['text'] = 
"Execute"<BR>b_execute['command'] = 
detail<BR>b_execute.pack()<BR>b_execute.grid(row=7, column = 
1)<BR>login.mainloop()</EM><BR></FONT></DIV>
<DIV><FONT size=2>The errors I'm getting:</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2><EM>Exception in Tkinter callback<BR>Traceback (most recent 
call last):<BR>  File "C:\Python22\lib\lib-tk\Tkinter.py", line 1292, in 
__call__<BR>    return apply(self.func, args)<BR>  File 
"C:\python scripts\teltest.py", line 9, in detail<BR>    
telnet.read_until("login: ")<BR>  File "C:\Python22\lib\telnetlib.py", line 
294, in read_until<BR>    while not self.eof and 
apply(select.select, s_args) == s_reply:<BR>  File 
"C:\Python22\lib\telnetlib.py", line 260, in fileno<BR>    return 
self.sock.fileno()<BR>AttributeError: 'NoneType' object has no attribute 
'fileno'<BR>Process terminated with exit code 0</EM></FONT></DIV></BODY></HTML>