home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
REXHLAPI.ZIP
/
REXTEST3.CMD
< prev
Wrap
OS/2 REXX Batch file
|
1991-03-20
|
8KB
|
208 lines
/**********************************************************************/
/* */
/* REXHLAPI.DLL Test Procrdure */
/* */
/* Author: W. David Ashley */
/* Date: 03/20/91 */
/* Version: 1.0 */
/* Release: 1 */
/* */
/* Notes: */
/* 1. Requires OS/2 Extended Edition 1.2 REXX interpreter. */
/* 2. Requires REXHLAPI.DLL in the LIBPATH. */
/* 3. Communications Manager should be running before beginning */
/* this procedure. */
/* 4. Be sure to change the USERID and PASSWORD variables before */
/* attempting to run this cmd. The host data set name should */
/* also be modified (see main processing loop). */
/* */
/* Log: */
/* 03/20/91 - Original issue. */
/* */
/**********************************************************************/
/* load REXHLAPI.DLL external function if not already loaded */
if rxfuncquery('REXHLLAPI') then ,
call rxfuncadd 'REXHLLAPI','REXHLAPI', 'REXHLLAPI'
/* Setup */
say 'Starting process.'
userid = 'zzzzz'
password = 'xxxxxx'
/* get Comm. Mgr. short session names */
session_info = REXHLLAPI('Query_sessions')
if length(session_info) < 13 then do
say 'No Comm. Mgr. sessions are active, canceling execution.'
exit
end
j = 1
session.0 = 0
do i = 13 by 12 for (length(session_info) / 12) - 1
if i > length(session_info) then leave
session.j = substr(session_info, i, 1)
j = j + 1
session.0 = session.0 + 1
end
/* main processing */
call logon
say 'Started download.'
dnldretc = 1
do while dnldretc \= 0
dnldretc = downloadfile('c:\testfile.txt ' || mysession ||,
/* your dsn goes here */
":'xxxxx.xxx.xxx(xxxxxx)' ascii crlf")
call waitforready
say 'Receive File Return Code =' dnldretc '.'
if dnldretc = 11 then do
say 'Host connection lost during file transfer.'
call logon
end
if dnldretc = 17 then do
say 'Host file does not exist.'
dnldretc = 0
end
end
call logoff
/* Exit */
say 'Finished all processing.'
exit
/**********************************************************************/
/**********************************************************************/
/******************** REXX Functions are below ************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* Log on to TSO procedure */
/**********************************************************************/
logon:
do while tsologon() \= 0
say 'Logon failure, will try again.'
end
return
/**********************************************************************/
/* TSO logon from VTAM procedure */
/**********************************************************************/
tsologon:
/* Find an unused session */
call tryconnect
do while mysession = -1
say 'All sessions active, will try again later.'
call REXHLLAPI 'Pause', 60
call tryconnect
end
say 'Connected to host.'
/* Set up the default session parameters */
call REXHLLAPI 'Set_Session_parms', 'SRCHFROM'
/* Send logon string to host */
call REXHLLAPI 'Sendkey', 'tso1 'userid',s3279m2'
call REXHLLAPI 'Sendkey', '@E' /* Enter */
call REXHLLAPI 'Pause', 20
if REXHLLAPI('Search_ps', '-OIDCARD', 1820) \= 0 then do
/* RACF screen now visible */
call REXHLLAPI 'Sendkey', password
call REXHLLAPI 'Sendkey', '@E' /* Enter */
readystatus = 0
do while readystatus = 0
call REXHLLAPI 'Pause', 10
if REXHLLAPI('Search_ps', 'ACF/VTAM DOMAIN', 1) \= 0 then do
say 'TSO session cancelled unexpectedly.'
return 1
end
if REXHLLAPI('Search_ps', 'READY', 1) \= 0 then readystatus = 1
if REXHLLAPI('Search_ps', ' *** ', 1840) \= 0 then do
if REXHLLAPI('Search_ps', 'READY', 1760) \= 0 then readystatus = 1
call REXHLLAPI 'Sendkey', '@E' /* Enter */
end
if REXHLLAPI('Search_ps', '-OIDCARD', 1820) \= 0 then do
say 'Your password has expired.'
exit
end
end
call REXHLLAPI 'Sendkey', '@C' /* Clear */
call REXHLLAPI 'Sendkey', 'term nobreak'
call REXHLLAPI 'Sendkey', '@E' /* Enter */
call waitforready
call REXHLLAPI 'Pause', 2
say 'Logged on to TSO.'
return 0
end
return 1
/**********************************************************************/
/* Try Session Connect procedure */
/**********************************************************************/
tryconnect:
/* disconnect from ps so we don't stack connections */
disconretc = REXHLLAPI('Disconnect_ps')
if session.0 > 0 then do j = 1 to session.0
mysession = session.j
conretc = REXHLLAPI('Connect_ps', mysession)
if conretc = 0 then do
if REXHLLAPI('Search_ps', 'ACF/VTAM DOMAIN', 1) \= 0 then do
return
end
end
else disconretc = REXHLLAPI('Disconnect_ps')
end
mysession = -1
return
/**********************************************************************/
/* Logoff of tso */
/**********************************************************************/
logoff: procedure
call REXHLLAPI 'Sendkey', 'logoff'
call REXHLLAPI 'Sendkey', '@E' /* Enter */
say 'Logged off of TSO.'
disconretc = REXHLLAPI('Disconnect_ps')
call REXHLLAPI 'Pause', 20
return
/**********************************************************************/
/* Wait for READY procedure */
/**********************************************************************/
waitforready:
do while 1
if REXHLLAPI('Search_ps', 'ACF/VTAM DOMAIN', 1) \= 0 then call error
if REXHLLAPI('Search_ps', 'UNSUPPORTED FUNCTION', 1) \= 0 then call error
if REXHLLAPI('Search_ps', ' *** ', 1) \= 0 then do
call REXHLLAPI 'Sendkey', '@E' /* Enter */
call REXHLLAPI 'Pause', 10
end
if REXHLLAPI('Search_ps', 'READY', 1) \= 0 then return
call REXHLLAPI 'Pause', 4
end
end
/**********************************************************************/
/* Download a file procedure */
/**********************************************************************/
downloadfile:
arg dnldparm
call REXHLLAPI 'Disconnect_ps'
dretc = REXHLLAPI('Receive_File', dnldparm)
if dretc = 3 | dretc = 4 | dretc = 27 then dretc = 0
call REXHLLAPI 'Connect_ps', mysession
return dretc
/**********************************************************************/
/* Error procedure */
/**********************************************************************/
error:
say 'TSO session cancelled unexpectedly.'
call logon
return