home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 3 Comm
/
03-Comm.zip
/
OS2SHKWQ.ZIP
/
OS2SHARE.CMD
Wrap
OS/2 REXX Batch file
|
1992-11-29
|
11KB
|
314 lines
/*-------------------------------------------------------------------*/
/* Log onto Pete Norloff's ShareWare BBS, upload pending KWQ REPs, */
/* download KWQ mail, once a day download Pete's Os2New.zip */
/* */
/* The script assumes your settings on the board are: */
/* expert toggled on, and protocol=Zmodem */
/* */
/* Timeouts are set assuming a reasonable number of new messages. */
/* If your last message in each forum isn't reasonable current, */
/* you'll time out. */
/* */
/* This script assumes you have set the PmComm32 memo field to a */
/* string that consists of "First name", "Last Name", and "Password" */
/* separated by white space. Example: */
/* */
/* Ron Hester mysecretpassword */
/* */
/* Be sure to the the "File Specs" below for your own system. */
/*-------------------------------------------------------------------*/
Signal ON SYNTAX NAME SYNTAX_ERROR
Parse arg port portname screen_handle dde_output dde_input semaphore
Parse source . . fn .
/* File Specs */
Reply_File="D:\PmComm\HostUp\Os2Share.rep" /* Packet to upload */
Capture_File="D:\PmComm\Capture\Os2Share.txt" /* Capture file */
Os2New="D:\PmComm\Files\Os2New.zip"
/* Constants */
cr = '0D'x
crlf = '0A0D'x
ctrl_K = '0B'x
esc = '1B'x
/* Environment Switches */
dcds = 1 /* modem supports dcd */
quiet = 0 /* change to 1 to disable audible alarms at suitable points */
debug = 0 /* change to 1 to activate some debugging stuff */
Call RxFuncAdd "Init_32dll","RxPmC32","Init_32dll"
Call Init_32dll
Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
Call SysLoadFuncs
Call Clear
Call Alarm
If debug then Call Put_s 'Executing' fn '...'||crlf,screen_handle
DownLoad_New=stream(Os2New,'c','query exists')=''
if \Download_New then
do
parse value stream(Os2New,'c','query datetime') with FDate ' ' .
Download_New=Fdate\=translate(date('U'),'-','/')
end
Download_New=DownLoad_New & time('h')>4
if debug then Call Put_s crlf"DownLoad_New="DownLoad_New||crlf,screen_handle
Call get_dial_memo dde_output,dde_input
parse var Result First_Name Last_Name Password
Call Read_timeout '20000',port
Do Forever
If dcds then Call Connected
Call Wait_fore "andle:",, /* 1 */
"irst name",, /* 2 */
"ast name",, /* 3 */
" name",, /* 4 */
"assword",, /* 5 */
"ape",, /* 6 */
",n]?",, /* 7 */
"graphics (",, /* 8 */
"olor?",, /* 9 */
"onStop:",, /* 10 */
"anguage #",, /* 11 */
"First Name",, /* 12 */
port,screen_handle
Match=Result
Call Flush
If debug then Call Put_s crlf"Match="Match||crlf,screen_handle
Select
When Match=1 then Call Put_s CS_Handle||cr,port
When Match=2 then Call Put_s First_Name||cr,port
When Match=3 then Call Put_s Last_Name||cr,port
When Match=4 then Call Put_s First_Name";"Last_Name||cr,port
When Match=5 then
Do
Call Put_s Password||cr,port
Leave
End
When Match=6 then
Do
Call Put_s esc,port
Call Sleep "250"
Call Put_s esc,port
End
When Match=7 | Match=8 | Match=9 then Call Put_s "y"cr,port
When Match=10 then Call Put_s "n"cr,port
When Match=11 then Call Put_s cr,port
When Match=12 then Call Put_s NewWareBBS";"Password||cr,port
When Match=0 then
Do
Call Alarm
If dcds then Call Connected
Call Put_s crlf"Unexpected timeout, script is exiting"crlf,screen_handle
Call Alarm
Exit /* If no match, go manual */
End
Otherwise Call Put_s cflf"Unexpected Match="Match" encountered and ignored"crlf,screen_handle
End
End
Call Read_timeout '90000',port
Do Forever
If dcds then Call Connected
Call Wait_fore " to continue ",, /* 1 */
" to continue?",, /* 2 */
"inue?",, /* 3 */
"ins updated",, /* 4 */
"ort scan.",, /* 5 */
"xecute ?",, /* 6 */
" go...",, /* 7 */
"k for mail",, /* 8 */
"k for new files",, /* 9 */
"ate to search from",, /* 10 */
"MAIN:",, /* 11 */
"ain:",, /* 12 */
"ommand?",, /* 13 */
"nter = ",, /* 14 */
"earching",, /* 15 */
"ore [",, /* 16 */
"*)NextArea]:",, /* 17 */
port,screen_handle
Match=Result
If Match\=5 & Match\=6 & Match\=7 & Match\=11 & Match\=12,
& Match\=13 & Match\=15 & Match\=17 then
Call Flush
if debug then Call Put_s crlf"Match="Match||crlf,screen_handle
Select
When Match=9 then
do
If DownLoad_New then
do
Call Put_s cr,port
Call Capture_on Capture_File,dde_output,dde_input
end
else
Call Put_s "n",port
end
When Match=1 | Match=10 | Match=14 then Call Put_s cr,port
When Match=3 | Match=8 | Match=16 then Call Put_s "n",port
When Match=2 | Match=4 | Match=17 then Call Put_s "n"cr,port
When Match=5 then Nop /* Call Put_s ctrl_K,port */ /* Suppress mail notification? */
When Match=6 | Match=7 | Match=11 | Match=12 | Match=13 then Leave
When Match=15 then nop /* allow more time for new files scan */
When Match=0 then
Do
If dcds then Call Connected
Call Alarm
Call Put_s crlf"Unexpected timeout, script is exiting"crlf,screen_handle
Call Alarm
Exit /* If no match, go manual */
End
Otherwise Call Put_s cflf"Unexpected Match="Match" encountered and ignored"crlf,screen_handle
End
End
If DownLoad_New then
Call Capture_off dde_output,dde_input
Call Put_s "o",port
Call Wait_fore "READER:",port,screen_handle
Call Flush
If dcds then Call Connected
if stream(Reply_File,'c','query exists')\='' then
do
Call put_s "u",port
Call wait_fore "cancel",port,screen_handle
Call Flush
Call zmodem_send Reply_File,dde_output,dde_input
Call Flush
Call wait_fore "READER:",port,screen_handle
Call Flush
Call SysFileDelete Reply_File
end
Call put_s "d",port
Call wait_fore "QWK format",,
"READER:",,
port,screen_handle
Match=Result
Call Flush
If dcds then Call Connected
Select
When Match=1 then
do
Call put_s cr,port
Call wait_fore "to abort:",port,screen_handle
Call Flush
Call put_s cr,port
Call wait_fore "to cancel.",port,screen_handle
Call zmodem_receive dde_output,dde_input
Call Read_timeout '120000',port
Call wait_fore "READER:",port,screen_handle
Call Flush
end
When Match=2 then
nop
Othewise
Exit
End
Call Read_timeout '90000',port
If Download_New then
do
Call SysFileDelete Os2New
Call put_s "m",port
Call wait_fore ":",port,screen_handle
Call put_s "f",port
Call wait_fore ":",port,screen_handle
Call put_s "d",port
Call wait_fore ":",port,screen_handle
Call put_s "Os2New"cr,port
Call wait_fore ":",port,screen_handle
Call put_s "/g"cr,port
Call wait_fore "to cancel.",port,screen_handle
Call Flush
Call zmodem_receive dde_output,dde_input
end
Else
do
Call put_s "g",port
Call wait_fore "nnect",port,screen_handle
Call Flush
Call put_s cr,port
Call wait_fore "rloff",port,screen_handle
Call Flush
Call put_s cr,port
End
If Debug then Call Put_s crlf"Script has completed"crlf||crlf,screen_handle
Call Alarm
Exit 0
/* Clear Screen Routine */
Clear: procedure expose screen_handle
Call put_s "1b5b324a"x,screen_handle
Return
/* A Procedure to see if the modem supports DCD and if see if we */
/* have a connection, if not then DROP the DTR and then RAISE the */
/* DTR again ... */
Connected: procedure expose port crlf screen_handle
Call DCD port
If result \= 1 then
Do
Call Beep 40,900
Call Put_s 'Carrier lost, script is terminating'||crlf,screen_handle
Call Drop_DTR port
Call Raise_DTR port
Exit
End
Return
/* speedy NBC noise, courtesy of Dr. Scott Mack */
Alarm: procedure expose quiet
If quiet then return
CALL BEEP 196,350
CALL BEEP 330,500
CALL BEEP 262,650
return
/*
Read and display any characters that were in the receive buffer at the time our wait_fore
hit a match. Do this since the match might not have been at the end of the string we are going
to respond to, so we want the accompanying characters to be processed and displayed. Don't
loop until get_ch fails, just in case we've matched something in the middle of a continuous
transmission that won't expect a response at this point.
*/
Flush: procedure expose port screen_handle crlf
Do while char_avail(port)>0
Call Put_s Get_ch(port),screen_handle
End
return
/* Standard handler for SIGNAL on ERROR, will help in the debugging */
syntax_error:
fp = filespec("path",fn)
fd = filespec("drive",fn)
errormsg='REXX error' rc 'in line' sigl':' errortext(rc)
errorfile = fd||fp||"SCRIPT.ERR"
rc = lineout(errorfile,date() time() fn '-' errormsg)
rc = lineout(errorfile,date() time() fn '-' sourceline(sigl))
Exit 8
/*
If debug then
Do
fp = filespec("path",fn)
fd = filespec("drive",fn)
capfile = fd||fp||"Debug.err"
call capture_on capfile,dde_output,dde_input
End
If debug then Call capture_off dde_output,dde_input
*/