home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / TSO.ZIP / TSO.CMD
OS/2 REXX Batch file  |  1991-06-05  |  3KB  |  146 lines

  1. /* REXX   Last update 05/03/91 - JEL
  2. **
  3. ** This command will signon to TSO
  4. ** based upon input to the command.  The password will be
  5. ** prompted for if not supplied.
  6. */
  7. '@ECHO off'
  8. /*
  9. ** Get command line input.  Set trace if requested.
  10. */
  11. parse upper arg trace .
  12.  
  13. if trace = 'TRACE' then do
  14.   trace ?r
  15.   parse upper arg trace parm1 parm2 parm3
  16. end
  17. else do
  18.   parse upper arg parm1 parm2 parm3
  19. end
  20.  
  21. call program_initialization
  22.  
  23. if connect_session() then do
  24.   call logon_to_tso
  25. end
  26.  
  27. if download = 'Y' then do
  28.   check_cnt  = 60                        
  29.   string_txt = 'PRIMARY OPTION'
  30.   call check_for_string 
  31.   call REXHLLAPI 'Sendkey', '6' '@E'
  32.   string_txt = 'TSO COMMAND'
  33.   call check_for_string
  34.   call REXHLLAPI 'Disconnect_ps' 
  35.   say 'Calling Download Program - DL.CMD.' 
  36.   call DL session_id telonsrc
  37.   call REXHLLAPI 'Connect_ps', session_id 
  38.   call REXHLLAPI 'Sendkey', '@3'
  39.  
  40. end
  41.  
  42. call disconnect_session
  43.  
  44. exit
  45. /*
  46. ** End of Mainline
  47. */
  48.  
  49.  
  50. program_initialization:
  51.   /*
  52.   **  Initialize variables, set boolean switches, strip leading
  53.   **  and trailing blanks from input parms (if necessary) etc.
  54.   */
  55.  
  56.   /*
  57.   ** load REXHLAPI.DLL external function if not already loaded
  58.   */
  59.   if rxfuncquery('REXHLLAPI') then ,
  60.     call rxfuncadd 'REXHLLAPI','REXHLAPI', 'REXHLLAPI'
  61.  
  62.   true            = 1
  63.   false           = 0
  64.   session_id      = 'B'
  65.   logon_id        = 'X04516'
  66.   password        = strip(parm1)
  67.   download        = strip(parm2)
  68.   telonsrc        = strip(parm3) 
  69.  
  70.   if password = '' then do
  71.     say
  72.     say 'Enter password:'
  73.     pull password
  74.   end
  75.   
  76.   return
  77.  
  78.  
  79. logon_to_tso:
  80.  
  81.   say
  82.   say 'Logging on to TSO...'
  83.   call REXHLLAPI 'Sendkey', 'TSO' logon_id '@E'
  84.  
  85.   string_txt = 'TSO/E  LOGON'
  86.   call check_for_string
  87.   
  88.   if string_not_found then do
  89.     say 'Host not responding.  Logon cancelled.'
  90.     return false
  91.   end
  92.  
  93.   call REXHLLAPI 'Sendkey', password '@E@E@E'
  94.   string_txt = '$$DRVR'
  95.   check_cnt  = 30
  96.   call check_for_string
  97.   call REXHLLAPI 'Sendkey', '@E'
  98.   say 'TSO Logon Completed.'
  99.  
  100.   return true
  101.  
  102.  
  103. connect_session:
  104.   if REXHLLAPI('Connect_ps', session_id) <> 0 then do
  105.     return false
  106.   end
  107.  
  108.   return true
  109.  
  110.  
  111. disconnect_session:
  112.   call REXHLLAPI 'Disconnect_ps'
  113.   return
  114.  
  115. check_for_string:
  116.  
  117.   string_not_found = true
  118.   string_found     = false
  119.  
  120.   if datatype(search_pos) <> 'NUM' then do
  121.     search_pos = 1
  122.   end
  123.  
  124.   if datatype(check_cnt) <> 'NUM' then do
  125.     check_cnt = 10
  126.   end
  127.  
  128.   do cnt = 1 to check_cnt while string_not_found 
  129.     if REXHLLAPI('Search_ps', string_txt, search_pos) <> 0 then do
  130.       string_not_found = false
  131.       string_found     = true
  132.     end
  133.     else do
  134.       call REXHLLAPI 'Pause', 2
  135.     end
  136.   end
  137.  
  138.   check_cnt     = 10   
  139.   search_pos    = 1
  140.   
  141.  
  142.   if string_not_found then do
  143.     return false
  144.   end
  145.  
  146.   return true