btjenkins at att.net
Tue Jun 4 10:22:41 EDT 2002
I am trying to write a script that combines telnet, FTP, and gzip
functionalities. Here is the process: open telnet connection, change
to new directory, list directory, grab last file in directory (the
file most recently added), and append it to a list. Then, close the
telnet connection and open an FTP connection and place the list I
created in a folder specified by user (through FTP connection). I
will then use gzip to open file and perform other actions.
Initially, I designed this to work with FTP only, but the project has
changed and I need to add telnet functionality. I have worked with
the script to the point where I can open a telnet account, change to
new directory, and list the directory's contents...but, I can't seem
to figure out how to grab the last file in the directory and append it
to the list. It seems that telnetlib doesn't offer that ability.
Here is what I am working with currently:
from ftplib import FTP
import string, sys
HOST = sys.argv
user = sys.argv
password = sys.argv
pw = 'sample'
tn = telnetlib.Telnet(HOST)
tn.write(user + "\n")
tn.write(password + "\n")
tn.write(pw + "\n")
#flist =  # I used these lines from my previous
#sdr = 
Any help would be greatly appreciated. My efforts to find advice has
not been very successful to date.
Thank you, in advance.
More information about the Python-list