PK> FTP connection status before I report that the connection was successful.
PK> FtpPwd() MUST obtain a Server response, and because it is
PK> "non-destructive" call, any access/permission issues on the FTP Server
PK> will mask the connection issue. Once the Login is confirmed, THEN I try
PK> and change directories...
In light of this tip, I've modified the script to separate the connection
check from the first directory change using the FtpSys() function.
I decided not to use FtpPwd() because it might, depending from the server's
configuration, be expensive on the server side. If an UNIX FTP server needs
to do a PWD, for example, it has to backtrack up the ".." links from whatever
the current directory is until it reaches the root. This will be non-trivial
if the server is configured to start in a non-root directory, and will involve
disc I/O. It seems unfriendly to make the server do all of that work and then
simply ignore the result. It seems especially unfriendly to do this to the
Hobbes FTP server.
Querying the operating system, by comparison, is far less expensive at the
server end, since it should at most cause the server to spit out as its
response a literal string that was compiled into its executable.
Here is the modified script:
-------------------------------------------------------------------------------
/* GET_GLOBAL.CMD -- Retrieve 00GLOBAL.TXT from Hobbes FTP site */
/*
* This is a REXX script that retrieves the 00GLOBAL.TXT file from the
* Hobbes OS/2 FTP site in New Mexico State University in the United State.
*
* (c) Copyright 1997-1999 Jonathan de Boyne Pollard. All rights reserved.
*
* Permission is hereby granted for you to use, copy, modify, and redistribute
* this script to your heart's content, as long as you make no money from
* doing so, and as long as you realise that I accept no responsibility for
* whatever posession or use of this script may do to your machine, data,
* cat, or marital status.
*
* NOTE: This script requires that you have installed the RxFTP library.
*/
call RxFuncAdd 'FtpLoadFuncs','RxFTP','FtpLoadFuncs'
rc = FtpLoadFuncs()
if FtpSetUser('hobbes.nmsu.edu', 'anonymous', 'os2user@') then do
say 'Successfully connected to hobbes.nmsu.edu.'
if FtpSys('opsys') >= 0 then do
if FtpChDir('/pub/os2') >= 0 then do
say 'Downloading "/pub/os2/00global.txt" ...'
if FtpGet('00global.txt', '00global.txt', 'Ascii') >= 0 then
say '"00global.txt" has been successfully retrieved'
else
say 'FTP error 'FtpErrNo' retrieving "00global.txt"'
end
else
say 'FTP error 'FtpErrNo' changing to directory "/pub/os2"'
end
else
say 'FTP error 'FtpErrNo' querying the remote server'
end
else
say 'Cannot log in to the Hobbes OS/2 FTP site !'
call FtpLogoff
-------------------------------------------------------------------------------
¯ JdeBP ®
--- FleetStreet 1.22 NR
209/7211
911
* Origin: JdeBP's point, using Squish (2:257/609.3)
|