FTP Library Package 1.2 for Tcl/Tk
<<< BACK TO HOMEPAGE | Introduction | Overview | Download | Installation | Examples
Introduction |
The library package consists of 100% pure tcl code, no extensions, no C stuff.
NOTE: The ftp_lib was frozen with release 1.2 and is no longer maintained at this site. |
What's new!!!:
What's new in release 1.2 (May 12, 1999) :
Command Overview |
For a complete description of each command please refer to the new HTML Online Manual Pages.FTP::Open <server> <user> <passwd> ?options? FTP::Close FTP::Cd <directory> FTP::Pwd FTP::Type <?ascii|binary?> FTP::List <?directory?> FTP::NList <?directory?> FTP::FileSize <file> FTP::ModTime <file> FTP::Delete <file> FTP::Rename <from> <to> FTP::Put <local> <?remote?> FTP::Append <local> <?remote?> FTP::Get <remote> <?local?> FTP::Reget <remote> <?local?> FTP::Newer <remote> <?local?> FTP::MkDir <directory> FTP::RmDir <directory> FTP::Quote <arg1> <arg2> ...
Download |
Installation Instructions |
If you do not have already installed tcl/tk 8.0, at first you must install it. Get it from the known locations and follow the installation instructions.
Download ftp_lib from these location.
Copy the compressed library package into a temporary directory. Unpack it dependent on operating system. Use Winzip for windows platforms and gunzip for UNIX.
Type ./install.tcl in the current directory or double click it in explorer or file manager window. A simple installation program is seen now. The installation program allows you to change the destination directory for the FTP library. The default directory is "/usr/local/lib" for UN*X and the Tcl/Tk distribution directory for Win*.
Some scripts are placed in the current directory that demonstrates the using of ftp_lib. One of them is called ftpdemo.tcl. It is a graphical user interface to test interactively the command set of ftp_lib in each environment. Check it out because not all FTP servers provides a complete set of FTP requests! I have used ftpdemo.tcl permanent during the development of ftp_lib.
Configure ftpdemo.tcl with your access data and your customized options! I also suggest to have a look at the script's source code to understand how ftp_lib works!
Some other example scripts are described below.
Examples |
The FTP library package can easily include into programs. Invoke
in your tcl code to load a suitable version of the FTP library package. I have written some example utilities to show the easily use of ftp_lib's commands.package require FTP 1.2
Example #1 - Directory Mirror
The script mirror.tcl is used to mirror a complete remote directory structure. It creates an exact copy of this structure on the locale machine. Three parameters needs to be modified to work properly, the hostname of the remote server, the username and the password for login.package require FTP 1.2 # user configuration set server noname set username anonymous set passwd xxxxxx # simple progress display proc ProgressBar {bytes} { puts -nonewline stdout "."; flush stdout } # recursive file transfer proc GetTree {{dir ""}} { catch {file mkdir $dir} foreach line [FTP::List $dir] { set rc [scan $line "%s %s %s %s %s %s %s %s %s %s %s" perm l u g size d1 d2 d3 name link linksource] if { ($name == ".") || ($name == "..") } {continue} set type [string range $perm 0 0] set name [file join $dir $name] switch -- $type { d {GetTree $name} l {catch {exec ln -s $linksource $name} msg} - {FTP::Get $name} } } } # main if {![FTP::Open $server $username $passwd -progress ProgressBar]} { puts "Connection refused!" exit 1 } GetTree FTP::Close
Example #2 - Software Update
The next few lines in newer.tcl are used to detect whether a new release of Brent Welch's phantastic tcl-httpd is present at scriptics ftp server. If FTP::Newer detects a newer file then it causes the upload process and sends me (as root) an email to inform about.package require FTP 1.2 if {![FTP::Open ftp.scriptics.com anonymous xxxx]} { puts "Connection refused!" exit 1 } if {[FTP::Newer /pub/tcl/httpd/tclhttpd.tar.gz /usr/local/src/tclhttpd.tgz]} { exec echo "New httpd arrived!" | mailx -s ANNOUNCE root } FTP::Close
Example #3 - Homepage Update
Quite a few people must have to keep permanent updating their homepages on a ISP server. My hpupdate.tcl is a tk-program for the interactive comparsion of the homepage directory on the local computer with the same directories on the remote homepage server. It is based on File Transfer Protocol. This process can be automated easily by hpupdate. It makes it quick and easy to keep the track of new/old or changed files.
Brief overview:Example #4 - TkCon command line ftp client
Loading the FTP Library Package into Jeffrey Hobbs' TkCon provides a simple ftp command line utility with command history. TkCon is a replacement for the standard console that comes with Tk. It must be started with the "package" option:
to load ftp_lib automatically. Here is a screenshot of a simple ftp session using TkCon. All examples can be found in the package distribution.tkcon -package FTP
|