home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 July / AMIGA_1996_7.BIN / patches / pagestream / 3.0cfupdate / macros.lha / PLcmdshell.rexx < prev    next >
OS/2 REXX Batch file  |  1994-04-20  |  2KB  |  72 lines

  1. /*
  2. ** $VER: CmdShell.rexx 1.0 ()
  3. **
  4. **
  5. */
  6.  
  7. options results
  8. options failat 100
  9.  
  10. open('console', 'CON:0/11/640/50/PageLiner', 'RW')
  11. writeln('console', 'Enter commands, "Q" to exit, "?" for help.')
  12.  
  13. address PAGELINER
  14.  
  15. /* loop until user exits */
  16. do forever
  17.  
  18.         /* get command string from user */
  19.         writech('console','CMD> ')
  20.         cmd=readln('console')
  21.  
  22.         select
  23.  
  24.                 /* time to quit? */
  25.                 when (upper(cmd) = "Q") then do
  26.                         leave
  27.                 end
  28.  
  29.                 /* need some help? */
  30.                 when (cmd = "?") then do
  31.                         writeln('console', 'Enter "<command> ?" to obtain a command''s template.')
  32.                         writeln('console', 'Enter "HELP <command>" to obtain more help on a command.')
  33.                         writeln('console', 'Enter "Q" or "Quit" to exit command shell.')
  34.                         writeln('console', 'Enter "REXX <command>" to execute rexx commands.')
  35.                 end
  36.  
  37.                 /* do nothing on empty lines */
  38.                 when (cmd = "") then do
  39.                         nop
  40.                 end
  41.  
  42.                 /* whatsinaline */
  43.                 otherwise do
  44.  
  45.                         /* if the commandstring starts with "rexx " interpret it as a rexx
  46.                                 instruction instead of a command */
  47.                         if upper(left(cmd,5)) = "REXX " then do
  48.                                 interpret right(cmd,length(cmd) - 5)
  49.                         end
  50.  
  51.                         else do
  52.                                 /* execute the command string */
  53.                                 cmd
  54.  
  55.                                 /* if ok show the result, if any */
  56.                                 if RC == 0 then do
  57.                                         if result ~= "RESULT" then writeln('console', result)
  58.                                         if (upper(cmd) = "QUIT") then leave
  59.                                 end
  60.  
  61.                                 else do
  62.                                         /* ERROR!!!!   get fault string from MCEd */
  63.                                         writeln('console', '*** Error');
  64.                                 end
  65.                         end
  66.                 end
  67.         end
  68. end
  69.  
  70. exit(0)
  71.  
  72.