home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
spewnew.zip
/
SpewNew.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-04-16
|
5KB
|
113 lines
/* A REXX/FTP routine to copy **new** files from LOCAL site to REMOTE site */
/* */
/* This routine finds all the files with the archive bit set on LOCAL and */
/* ftp's them to the equivalent spot on REMOTE. It then turns off the */
/* archive bit on the files once they have been transferred. */
/* */
/* Usage: SPEWNEW \LOCALDIR ftp.remote.ca/pub/remote */
/* where '\LOCALDIR' is the local directory root to begin searching down from*/
/* 'ftp.remote.ca' is the ftp server to reach */
/* '/pub/remote' is the remote directory root on the remote server */
/* */
/* You must have the IBM EWS rexx FTP module called "rxftp". It is available*/
/* on the internet from hobbes or www.cdrom.com, or from the IBM support*/
/* bulletin boards. */
/* Written by Alex Doll (adoll@fdva.com) to automate maintenance of the*/
/* Canadian Inst of Mine image archive at www.mining.ubc.ca/images (plug, plug)*/
/* This software is free, so you get what you pay for. There are no guarentees*/
/* that it will work for you, nor will the author or distributor be liable for*/
/* any damage that it does to your system.*/
/* */
/* Hint for Windows users... here's a quick way to get rid of all those */
/* Windows based system crashes: */
/* type 'format c: /s' from the command line, and you'll never see */
/* windows crash your system again! */
parse arg LocalDir RemotePath LoginID LoginPassword
/* parse the command line into a local directory and a remote server and directory, */
/* and login ID and password */
if RemotePath="" then do
say ""
say "SpewNew.cmd usage:"
say " SPEWNEW \LOCALDIR ftp.remote.ca/pub/remote [loginID] [password]"
say ""
say "where '\LOCALDIR' is the local directory root to begin searching down from"
say " 'ftp.remote.ca' is the ftp server to reach"
say " '/pub/remote' is the remote directory root on the remote server"
say " [loginID] (optional) the login ID to use entering the FTP server"
say " [password] (optional) the password to use entering the FTP server"
exit -1
end
/* parse the RemotePath (from above) to obtain an FTP server name (that we'll */
/* log into) and a path name (that we'll "cd" to) */
parse value RemotePath with RemoteHost"/"RemotePath
if LoginID="" then do
LoginID="anonymous"
say "attempting anonymous FTP login. Some FTP machines may not allow"
say "anonymous logins."
end /*if*/
if LoginPassword="" then LoginPassword="SpewNew.Rexx.Script@somebodys.os2.machine"
say "Attempting to attach FTP functions from rxFTP.DLL file"
rc = RxFuncAdd("FtpLoadFuncs","rxFtp","FtpLoadFuncs")
if rc<>0 then do
say "ERROR "rc" ##### UNABLE TO LOAD rxFtp.dll! #####"
say "You did install the rexx ftp functions from the IBM EWS package, didn't you?"
exit -1
end /*if*/
rc = FtpLoadFuncs()
/* Try logging in and checking the directory on REMOTE */
say "Attempting to connect to "RemoteHost
rc=FtpSetUser( RemoteHost, LoginID, LoginPassword)
if rc=-1 then do
say "****ERROR**** "FtpErrNo
exit -1
end /*if*/
say "Changing to /"RemotePath
rc=FtpChDir( "/"RemotePath)
if rc=-1 then do
say "!!!!ERROR!!!! "FtpErrNo
exit -1
end /*if*/
/* OK, if I get this far, then I'm logged in and ready to go to work. */
/* The first thing to do is build a list of the files on LOCAL that need */
/* to be spewed over to the remote machine. */
LocalPath=Directory(LocalDir)'\'
say "Useing "localPath" as local directory"
'dir /b /s /aa *.* > SpewTemp.txt'
RC=stream( 'SpewTemp.txt', 'c', 'close')
/* Setting binary transfer - I'm too lazy to check for ascii files! */
rc=FtpSetBinary( "Binary")
/* Transfer each of the file names contained in SPEWTEMP.TXT */
do while Lines('SpewTemp.txt')
aVictim=LineIn('SpewTemp.txt')
/* double check that the directory is correct */
if (TRANSLATE(left(aVictim,length(localPath)))=TRANSLATE(localPath)) then do
aVictim=right(aVictim, length(aVictim)-length(localPath))
RemoteVictim=Translate( aVictim, "/", "\")
say "Transferring file "RemoteVictim
rc=FtpPut(aVictim, RemoteVictim)
if FtpErrNo<>0 then say "!!!!ERROR!!!! "FtpErrNo
else
'@attrib -a 'aVictim
end
else
say "found ineligible file : "aVictim
end /* do */
/* All files transferred! Log off and shut everything down */
say "all done. Cleaning up"
RC=stream( 'SpewTemp.txt', 'c', 'close')
'erase SpewTemp.txt'
/*call FtpLogoff()*/
rc=FtpDropFuncs()