The requirement for this arose when I wanted to see whether a new
version of the SDD drivers had appeared on the IBM DDPak web site.
I got bored of trawling through the awkward IBM web pages to see.
Also we get charged by use of the Internet connection that we use at work
but, oddly enough, not for the FTP use we make.
So I decided to write some more REXX in a spare morning I had to do the job. It lists the files in European date order (that is DD/MM/YYYY), but it should be easy enough for you to change it if you want.
It works behind a firewall, and also through a normal modem connection. It creates an output file called DDPAKDIR.TXT for you to do with what you will. It can be modified to look at any ftp site.
/****************************************************************************/
/* Filename : DDPAKDIR.CMD
*/
/*
*/
/* Author : Colin Haynes
*/
/*
: colin@haynes97.freeserve.co.uk
*/
/*
*/
/* Date : 20th April 2000
*/
/*
*/
/* Version : 1.0
*/
/*
*/
/* Purpose : List all files in ftp.boulder.ibm.com/ps/products/os2/os2ddpak*/
/*
: in DD/MM/YYYY order to see if any new files have appeared
*/
/*
*/
/* Comments : Works behind a firewall if you want.
*/
/*
: This is freeware, but is copyright Colin Haynes
*/
/*
: If you happen to use it anywhere, or use it as the basis for */
/*
: anything else, please give me a mention somewhere.
*/
/*
*/
/* Outputs : Creates and removes temporary
files output.txt and
*/
/*
: output1.txt in current directory. Final output file is
*/
/*
: DDPAKDIR.TXT in current directory
*/
/****************************************************************************/
/****************************************************************************/
/* Load standard REXX functions
*/
/****************************************************************************/
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
/****************************************************************************/
/* Load standard REXX FTP functions and make them
not display the copyright */
/****************************************************************************/
rc = RxFuncAdd("FtpLoadFuncs","rxFtp","FtpLoadFuncs")
rc = FtpLoadFuncs(No_Copyright_Text)
/****************************************************************************/
/* Set the userid for the remote site
*/
/* host is proxyname if you're behind a proxy or
ftp.boulder.ibm.com if not */
/* userid is anonymous@ftp.boulder.ibm.com if behind
a proxy or anonymous */
/* if not
*/
/* password is emailid
*/
/****************************************************************************/
host = 'ftp.boulder.ibm.com'
userid = 'anonymous'
password = 'youremailid@your.isp.provider'
rc = FtpSetUser(host,userid,password,)
/****************************************************************************/
/* Change to correct directory on boulder
*/
/****************************************************************************/
rc = FtpChDir('ps/products/os2/os2ddpak')
/****************************************************************************/
/* Get directory list in verbose mode to stem variable
dirlist
*/
/****************************************************************************/
rc = FtpDir("*","dirlist.")
/****************************************************************************/
/* Loop round and sort out formatting so everything
lines up
*/
/* If no year is found, it's this year, so put that
in as well
*/
/****************************************************************************/
Thisyear = RIGHT(DATE('N'),4)
do n = 1 to dirlist.0
if (SUBSTR(dirlist.n,49,1))=" " then
dirlist.n = LEFT(dirlist.n,30)||SUBSTR(dirlist.n,32,LENGTH(dirlist.n))
if (SUBSTR(dirlist.n,46,1))=" " then
dirlist.n = LEFT(dirlist.n,45)||"0"||SUBSTR(dirlist.n,47,LENGTH(dirlist.n))
select
when SUBSTR(dirlist.n,42,3)
= 'Jan' then month ="01"
when SUBSTR(dirlist.n,42,3)
= 'Feb' then month ="02"
when SUBSTR(dirlist.n,42,3)
= 'Mar' then month ="03"
when SUBSTR(dirlist.n,42,3)
= 'Apr' then month ="04"
when SUBSTR(dirlist.n,42,3)
= 'May' then month ="05"
when SUBSTR(dirlist.n,42,3)
= 'Jun' then month ="06"
when SUBSTR(dirlist.n,42,3)
= 'Jul' then month ="07"
when SUBSTR(dirlist.n,42,3)
= 'Aug' then month ="08"
when SUBSTR(dirlist.n,42,3)
= 'Sep' then month ="09"
when SUBSTR(dirlist.n,42,3)
= 'Oct' then month ="10"
when SUBSTR(dirlist.n,42,3)
= 'Nov' then month ="11"
when SUBSTR(dirlist.n,42,3)
= 'Dec' then month ="12"
end
if SUBSTR(dirlist.n,51,1) = ":" then
dirlist.n = LEFT(dirlist.n,48)||Thisyear||SUBSTR(dirlist.n,53,LENGTH(dirlist.n))
Day = SUBSTR(dirlist.n,46,2)
Year = SUBSTR(dirlist.n,49,4)
Filename = SUBSTR(dirlist.n,55,LENGTH(dirlist.n))
outputline = Year||Month||Day||" "||Filename
rc = lineout("output.txt",outputline)
end
/****************************************************************************/
/* Having done all this, sort the ouput into date
order
*/
/****************************************************************************/
'@sort <output.txt>output1.txt'
/****************************************************************************/
/* Then, format it into DD/MM/YYYY filename order
*/
/****************************************************************************/
do while LINES("output1.txt")
in = linein('output1.txt')
outputline = SUBSTR(in,7,2)||"/"||SUBSTR(in,5,2)||"/"SUBSTR(in,1,4)||"
"||SUBSTR(in,10,LENGTH(in))
rc = lineout("DDPAKDIR.TXT",outputline)
end
/****************************************************************************/
/* Close all files and remove temporary files
*/
/****************************************************************************/
rc = lineout("output.txt")
rc = lineout("output1.txt")
rc = lineout("DDPAKDIR.TXT")
rc = SysFileDelete('output.txt')
rc = SysFileDelete('output1.txt')
/****************************************************************************/
/* Drop everything (oooer Missus)
*/
/****************************************************************************/
rc = FtpLogoff()
rc = FtpDropFuncs()
rc = SysDropFuncs()
I welcome any criticism.
Email me if you want some more information.
Version 1.0
Date 21/04/2000