      SUBROUTINE MAIN
      INTEGER FOUND, REPS, SECS, I, GETARG, J, N, CTOI, LENGTH, SSPAWN, 
     *ASTART
      INTEGER LOCCOM
      LOGICAL*1 ARG(512), PROCES(40), DESCR(7), CLOWER
      LOGICAL*1 SUFFIX(7)
      LOGICAL*1 SH(3)
      LOGICAL*1 ARGS(256)
      LOGICAL*1 USESTR(55)
      DATA SUFFIX(1)/46/,SUFFIX(2)/116/,SUFFIX(3)/115/,SUFFIX(4)/107/,SU
     *FFIX(5)/0/,SUFFIX(6)/10/,SUFFIX(7)/0/
      DATA SH(1)/115/,SH(2)/104/,SH(3)/0/
      DATA ARGS(1)/115/,ARGS(2)/104/,ARGS(3)/32/,ARGS(4)/45/,ARGS(5)/99/
     *,ARGS(6)/32/,ARGS(7)/0/
      DATA USESTR(1)/117/,USESTR(2)/115/,USESTR(3)/97/,USESTR(4)/103/,US
     *ESTR(5)/101/,USESTR(6)/58/,USESTR(7)/32/,USESTR(8)/32/,USESTR(9)/1
     *15/,USESTR(10)/99/,USESTR(11)/104/,USESTR(12)/101/,USESTR(13)/100/
     *,USESTR(14)/32/,USESTR(15)/91/,USESTR(16)/45/,USESTR(17)/114/,USES
     *TR(18)/60/,USESTR(19)/114/,USESTR(20)/101/,USESTR(21)/112/,USESTR(
     *22)/115/,USESTR(23)/62/,USESTR(24)/93/,USESTR(25)/32/,USESTR(26)/9
     *1/,USESTR(27)/45/,USESTR(28)/116/,USESTR(29)/60/,USESTR(30)/115/,U
     *SESTR(31)/101/,USESTR(32)/99/,USESTR(33)/111/,USESTR(34)/110/,USES
     *TR(35)/100/,USESTR(36)/115/,USESTR(37)/62/,USESTR(38)/93/,USESTR(3
     *9)/32/,USESTR(40)/34/,USESTR(41)/115/,USESTR(42)/104/,USESTR(43)/1
     *01/,USESTR(44)/108/,USESTR(45)/108/,USESTR(46)/32/,USESTR(47)/99/,
     *USESTR(48)/111/,USESTR(49)/109/,USESTR(50)/109/,USESTR(51)/97/,USE
     *STR(52)/110/,USESTR(53)/100/,USESTR(54)/34/,USESTR(55)/0/
      CALL QUERY(USESTR)
      ASTART = LENGTH(ARGS) + 1
      FOUND = 0
      REPS = 1
      SECS = 1
      I=1
23000 IF (.NOT.(GETARG(I, ARG, 512) .NE. -1))GOTO 23002
      IF (.NOT.(ARG(1) .EQ. 45 .AND. CLOWER(ARG(2)) .EQ. 114))GOTO 23003
      J = 3
      N = CTOI(ARG, J)
      IF (.NOT.(N .LT. 1))GOTO 23005
      REPS = 1
      GOTO 23006
23005 CONTINUE
      IF (.NOT.(N .GT. 30000))GOTO 23007
      REPS = 30000
      GOTO 23008
23007 CONTINUE
      REPS = N
23008 CONTINUE
23006 CONTINUE
      GOTO 23004
23003 CONTINUE
      IF (.NOT.(ARG(1) .EQ. 45 .AND. CLOWER(ARG(2)) .EQ. 116))GOTO 23009
      J = 3
      SECS = CTOI(ARG, J)
      GOTO 23010
23009 CONTINUE
      FOUND = 1
      CALL SCOPY(ARG, 1, ARGS, ASTART)
23010 CONTINUE
23004 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF (.NOT.(FOUND .EQ. 0))GOTO 23011
      CALL ERROR(USESTR)
23011 CONTINUE
      CALL IMPATH(ARG)
      IF (.NOT.(LOCCOM(SH, ARG, SUFFIX, PROCES) .NE. 60))GOTO 23013
      CALL ERROR(32HError locating shell image file.)
23013 CONTINUE
      I=1
23015 IF (.NOT.(I .LE. REPS))GOTO 23017
      CALL SLEEP(SECS)
      IF (.NOT.(SSPAWN(PROCES, ARGS, DESCR, 119) .EQ. -3))GOTO 23018
      CALL ERROR(25HError in spawning command)
23018 CONTINUE
23016 I=I+1
      GOTO 23015
23017 CONTINUE
      RETURN
      END
