* CMDSHELL - Unix shell "emulator", so you don't need a Unix-like environment
* executes given shell commands (cmdshell -ce "...") on the OS/2 (or Windows)
* command interpreter
* executes DEL instead of RM, COPY instead of CP, MOVE instead of MV
* DIR instead of LS -> converts / to \
* use setenv SHELL=cmdshell.exe in a cookbook
* PUBLIC DOMAIN

      program CMDSHELL
       implicit integer(A-Z)
       include 'fsublib.fi'
       character*256 cmdargs, toexec, newexec
       character*40  lowc, conv(8)/'rm','del','cp','copy',
     &                             'mv','move','ls','dir'/

       cmdlen = FGETCMD(cmdargs)

       ! just get the actual command
       toexec = cmdargs(index(cmdargs, '"')+1:cmdlen-1)

       ! eventually replace command name with OS/2-Windows one
       lowc = toexec(:index(toexec, ' ')-1)
       do x=1, 8, 2
        if(conv(x) .EQ. lowc) then
         newexec = conv(x+1)(:lentrim(conv(x+1)))//
     &             toexec(index(toexec, ' '):)
         ! convert slashes to backslashes
         do n=index(newexec, ' ')+1, lentrim(newexec)
          if(newexec(n:n) .EQ. '/') newexec(n:n) = '\'
         end do
         toexec = newexec
         exit
        end if
       end do

       ! execute the damn thing
       call FSYSTEM(toexec(:lentrim(toexec)))
      end
