home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
mailftp.zip
/
ftp-sstar.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-12-08
|
14KB
|
330 lines
/* You will need to look over the whole script and make modifications */
/* to anything that is specific for your site. This script looks for */
/* mail here and sends it to George's system and picks up everything on */
/* hold for me there. It works for me (wish I had commented it better now...) */
/* I can't say it will work for you.*/ /* Good luck. */
/* This script was made up of the original file contained within FtpFido.Zip *
* With the help of examples from all those generous folks out there releasing *
* Rexx scripts without compiling I say thanks! This mod is released in the *
* same spirit in hopes someone out there can make it even better! 27-Oct-1995 */
/* Modified to connect to Southern Star via IHUB account for same */
/************************************************************************************************
* 10/95 - started from the command line in an OS/2 window, using PPPDIAL.CMD as
* the script launched from the Dialer in Warp's Bonus Pack... more to come as
* I have time and gain more experience... Hopefully I'll at least complete enough
* logging to hold over until some good error trapping can be implimented
* - rgwallen@datasync.com - 1995
* Scripts working in conjunction with same and that are required:
- STARTPPP.CMD Startup Script to begin session
- PPPDIAL.CMD [V2.7] available from many OS/2 ftp sites by Don Russell
send e-mail to: drussell@direct.ca
- FTP-SSTAR.CMD ftp script to connect to IHUB (req' RXFTP.DLL)
- DATASYNC.RSP Response file used with PPPDIAL
o rexx script to get FidoNet mail from Ftp.Sstar.Com
o this script attempts to keep a running log of files received
o added date, time and formatted output to log...
- Need desperately adding err trapping routines for: 17-Nov-1995
o failed ftp login session - completed
. drop connection during ftp trans - need this asap!
. need associated logging for error routines
- need to add dialer vars for provider connection and login - now using PPPDIAL
************************************************************************************************/
/* trace ?A */
trace off
/*------------------------------------------------------------------
* load functions, if needed
*------------------------------------------------------------------*/
if RxFuncQuery("FtpLoadFuncs") then
do
rc = RxFuncAdd("FtpLoadFuncs","RxFtp","FtpLoadFuncs")
rc = FtpLoadFuncs(quiet)
rc = FtpSetBinary('Binary') /* set all transfers to binary */
end
if RxFuncQuery("SysLoadFuncs") then
do
rc = RxFuncAdd("SysLoadFuncs","RexxUtil","SysLoadFuncs")
rc = SysLoadFuncs()
end
rc = FtpVersion(prtver) /* Get RxFTP version from DLL */
call syssleep (5) /* delay startup to ensure PPP session completes */
version = ".43" /* Setup constants for this session */
provider = "datasync"
NumToDial = "476-8154"
ipremote = ""
iplocal = ""
/* ALL Pathnames used below must exist! - no checking is performed so edit to meet requirements */
mailhost = "ftp.*****.com" /* ftp site name */
name = "****.***" /* your account name for IHUB */
password = "*****" /* your session password for IHUB */
ftpinbound = "/ihub/****_***/in" /* rem unix format for ftp inbound */
ftpoutbound = "/ihub/****_***/out" /* ftp site outbound */
ftphome = "/ihub/****_***" /* ftp site home */
inbound = "c:\adept\mailer\ftpinbound" /* local inbound to receive */
outbound = "c:\adept\mailer\sstar" /* local outbound to send */
home = "c:\adept\mailer" /* location of ihub.bsy file */
tossinbound = "c:\adept\mailer\password" /* inbound for mail processer */
log = "c:\logs\fidoFtp.log" /* logfile location & name */
sendmail = "03a97af6.*" /* archived filename for mail to uplink */
domailflag = "c:\adept\mailer\flags\do_mail.flg" /* semaphore to allow mail script to run */
doftpflag = "c:\adept\mailer\flags\doing_ftp.flg" /* ftp insession semaphore */
/************************************************************************************************
* You shouldn't have to change anything below - if you are familiar with Rexx have at it! *
************************************************************************************************/
say /* Introduction */
say "Ftp-Sstar Rexx Script, Version "version
say "Created in Nov of 1995, This program is freeware"
say "to promote Team OS/2 style Rexx support/sharing"
say
say "RxFtp DLL Version used is v"prtver
say
total_received = 0 /* reset counters for this session */
total_sent = 0
total_files = 0
Verbose = 0
/* initialize error trapping vars */
rxFtpErr = 0
rxFtp.FTPSERVICE = 10
rxFtp.FTPHOST = 11
rxFtp.FTPSOCKET = 12
rxFtp.FTPCONNECT = 13
rxFtp.FTPLOGIN = 14
rxFtp.FTPABORT = 15
rxFtp.FTPLOCALFILE = 16
rxFtp.FTPDATACONN = 17
rxFtp.FTPCOMMAND = 18
rxFtp.FTPPROXYTHIRD = 19
rxFtp.FTPNOPRIMARY = 20
'echo. >'doftpflag /* semaphore used during ftp session */
elapsed = substr(time('e'),9,1)
day = left(date('E'),2) /* logfile day formatted leading 0 */
mon = left(date('M'),3) /* logfile month formatted */
rc = stream(log,'C','open write') /* create if not exist and write to log */
rc = lineout(log,' ')
rc = lineout(log,''day' 'mon' 'time()' FTP begin, FtpSys Rexx OS/2')
rc = lineout(log,''day' 'mon' 'time()' FTP RxFtp DLL version is v'prtver)
rc = lineout(log,''day' 'mon' 'time()' FTP Attempting FTP linkup with' mailhost)
rc = FtpSetUser(mailhost, name, password)
attached = FtpSys(siteinfo) /* get site info */
say attached
rc = lineout(log,''day' 'mon' 'time()' FTP System Info 'attached)
len = length(attached)
say 'len = 'len
if len > 8 then
do
rc = lineout(log,''day' 'mon' 'time()' FTP Rexx System Login to 'mailhost 'successful')
say 'Login successful'
rc = FtpChDir(ftphome) /* change to remote home directory */
call directory home
rc = lineout(log,''day' 'mon' 'time()' FTP Posting ihub.bsy flag into IHUB home directory')
say ' Posting ihub.bsy flag into IHUB home directory'
rc = FtpPut('ihub.bsy','ihub.bsy') /* Post ihub.bsy flag */
call flofiles /* check for other archived mail files to send sstar.com */
call directory outbound
rc = SysFileTree(sendmail,outfile.,"F") /* Change to match your uplinks mail */
if outfile.0 > 0 then
do
rc = FtpChDir(ftpinbound) /* change to rem inbound */
call directory outbound /* change to local outbound */
rc = lineout(log,''day' 'mon' 'time()' FTP sending 'outfile.0' files')
say ' sending 'outfile.0' files'
x = 1
do outfile.0 /* loop through all the files here */
rc = lineout(log,''day' 'mon' 'time()' FTP sending 'word(outfile.x,5))
say ' sending 'word(outfile.x,5) ' - 'word(outfile.x,3)' bytes'
filename = filespec("name", word(outfile.x,5))
rc = FtpPut(filename, filename, 'binary')
/* add code to test for good transfer by filesize */
rc = FtpDir(filename,test.) /* get size from remote */
if test.0 = 1 then /* it did get there */
do
sizethere = word(test.1,5)
sizehere = word(outfile.x,3)
if sizehere = sizethere then /* if the same size, delete */
do
total_sent = total_sent + sizethere /* get size for report */
rc = lineout(log,''day' 'mon' 'time()' FTP Successful - Deleting 'word(outfile.x,5))
say ' Deleting 'outfile.x
rc = SysFileDelete(word(outfile.x,5))
end
else
do
rc = lineout(log,''day' 'mon' 'time()' FTP UN-Successful - Deleting 'word(outfile.x,5) 'from inbound')
say ' Deleting 'outfile.x
SysFileDelete(word(outfile.x,5))
end
end
x = x + 1 /* go to the next file */
end
end
else
do
say 'nothing to send at this time'
rc = lineout(log,''day' 'mon' 'time()' FTP Nothing to send at this time')
end
rc = FtpChDir(ftpoutbound) /* change to remote outbound */
call directory inbound
rc = Ftpdir('*.*',infile.) /* get list of files there for transfer */
x = 1 /* reset the pointer */
if infile.0 > 1 then
do
say ' Receiving 'infile.0 -1 'file(s)'
rc = lineout(log,''day' 'mon' 'time()' FTP Receiving 'infile.0 -1 'file(s)')
end
if infile.0 > 1 & rc = 0 then
/* time to get files here from There */
do infile.0
test = pos('incoming',infile.x) /* see if "incoming" is the next file */
if test = 0 then /* if it isn't, transfer the file */
do
filename = word(infile.x,9)
say ' Recieving 'filename '- 'word(infile.x,5) 'bytes'
start = time('e')
rc = FtpGet(filename, filename,"binary") /* Transfer the file */
elapsed = time('e')
sizehere = stream(filename,'C','query size') /* get the filesize here */
transfilespeed = sizehere / (elapsed - start)
rc = lineout(log,''day' 'mon' 'time()' FTP received 'filename '-' sizehere' bytes received at 'format(transfilespeed,5,1) 'cps')
if sizehere = word(infile.x,5) then
do
total_received = total_received + sizehere
say ' Deleting 'filename
rc = lineout(log,''day' 'mon' 'time()' FTP Deleting 'filename)
rc = FtpDelete(filename)
total_files = total_files + 1
say ' Received 'total_files 'file(s)'
end
end
x = x + 1
end
else
do
rc = lineout(log,''day' 'mon' 'time()' FTP No files to get')
say ' No files to get'
end
rc = FtpChDir(ftphome) /* change to remote home dir */
rc = FtpDelete('ihub.bsy') /* delete semaphore on remote */
rc = lineout(log,''day' 'mon' 'time()' FTP Deleting ihub.bsy')
rc = FtpLogoff()
end
else
do
say '!Login failed... session aborted'
rc = lineout(log,''day' 'mon' 'time()' FTP !Login failed... session aborted')
end
Abort:
if aborted = 1 then rc = lineout(log,''day' 'mon' 'time()' FTP File transfer failed... Session Aborted')
call directory 'c:\tcpip\bin' /* make sure the drive is correct */
'ppp com2 exit'
call syssleep 3
if total_files > 0 then
'echo. >'domailflag /* semaphore to check for to launch your tosser */
total = total_sent+total_received
elapsed = time('e')
avgcps = total / elapsed
say ' Sent 'total_sent 'bytes, received 'total_received 'bytes in 'elapsed%60 'minutes, 'elapsed//60 ' seconds.'
say ' Averaging 'format(avgcps,5,1)' cps for this session'
rc = lineout(log,''day' 'mon' 'time()' FTP Sent 'total_sent 'bytes, received 'total_received 'bytes in 'elapsed%60 'minutes, 'format(elapsed//60,5,1) 'seconds.')
rc = lineout(log,''day' 'mon' 'time()' FTP Averaging 'format(avgcps,5,1) 'cps for this session')
rc = lineout(log,''day' 'mon' 'time()' FTP received 'total_files 'file(s)')
/* adding logic to copy files from ftpincoming to protected inbound for processing */
if total_files > 1 then
do
rc = lineout(log,''day' 'mon' 'time()' FTP Moving files from 'inbound' to 'tossinbound)
say 'Moving files from 'inbound' to 'tossinbound '...'
call directory inbound
PARSE VAR tossinbound drive ':' tossinbound /* strip drive designator so move will work */
'move *.* 'tossinbound /* move files in ftp rec'ing dir to tosser inbound */
end
rc = lineout(log,''day' 'mon' 'time()' FTP end session, FtpSys Rexx OS/2 v'prtver)
say ' FTP end session, FtpSys Rexx OS/2 v'prtver
rc = stream(log,'C','close')
call syssleep (5)
call directory 'c:\tcpip\bin'
'erase 'doftpflag /* Delete semaphore so FTP1 can terminate */
exit /* window will close when parent process terminates */
/* ------------------------procedure------------------------ */
FloFiles:
rc = FtpChDir(ftpinbound) /* cd to remote inbound */
call directory outbound /* cd to local outbound */
rc = SysFileTree(sendmail,files.,"F") /* send all files for sstar */
say 'total files 'files.0
if files.0 > 0 then
do
rc = lineout(log,''day' 'mon' 'time()' FTP sending 'files.0' files')
say ' sending 'files.0' files'
x = 1
do files.0 /* loop through all the files here */
rc = lineout(log,''day' 'mon' 'time()' FTP sending 'word(files.x,5))
say ' sending 'word(files.x,5) ' - 'word(files.x,3)' bytes'
filename = filespec("name", word(files.x,5))
rc = FtpPut(filename, filename, 'binary')
/* add code to test for good transfer by filesize */
rc = FtpDir(filename,test.) /* get size from remote */
if test.0 = 1 then /* it did get there */
do
sizethere = word(test.1,5)
sizehere = word(files.x,3)
if sizehere = sizethere then /* if the same size, delete */
do
total_sent = total_sent + sizethere /* get size for report */
rc = lineout(log,''day' 'mon' 'time()' FTP Successful - Deleting 'word(files.x,5))
say ' Deleting 'files.x
rc = SysFileDelete(word(files.x,5))
end
end
x = x + 1 /* go to the next file */
end
end
return