Specifications
?>
</body>
</html>
The output from running this script on one occasion is shown in Figure 17.4.
Using Network and Protocol Functions
C
HAPTER 17
17
USING NETWORK
AND
PROTOCOL
FUNCTIONS
381
LISTING 17.4 Continued
FIGURE 17.4
The FTP mirroring script checks whether the local version of a file is up-to-date, and downloads a new version if not.
This is quite a generic script. You’ll see that it begins by setting up some variables:
$host = “ftp.cs.rmit.edu.au”;
$user = “anonymous”;
$password = “laura@tangledweb.com.au”;
$remotefile = “/pub/tsg/ttssh14.zip”;
$localfile = “$DOCUMENT_ROOT/../writable/ttssh14.zip”;
The $host variable should contain the name of the FTP server you want to connect to, and the
$user and $password correspond to the username and password you would like to log in with.
Many FTP sites support what is called anonymous login, that is, a freely available username
that anybody can use to connect. No password is required, but it is a common courtesy to sup-
ply your email address as a password so that the system’s administrators can see where their
users are coming from. We have followed this convention here.
The $remotefile variable contains the path to the file we would like to download. In this case
we are downloading and mirroring a local copy of Tera Term SSH, an SSH client for Windows.
(SSH stands for secure shell. This is an encrypted form of Telnet.)
The $localfile variable contains the path to the location where we are going to store the
downloaded file on our machine.
You should be able to change these variables to adapt this script for your purposes.
22 7842 CH17 3/6/01 3:39 PM Page 381










