home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / ftpfid17.zip / HANGUP.CMD < prev    next >
OS/2 REXX Batch file  |  1996-09-14  |  4KB  |  157 lines

  1. /* Hangup.cmd */
  2. parse arg ftproc
  3. '@echo off'
  4.  
  5. hangupflg = 'f:\bbs\logs\hangup.flg' /* Tells CSPPP to hangup */
  6. ftpflg = 'f:\bbs\logs\Doing_ftp.flg' /* FTPFIDO process flag */
  7. hisbsy = 'f:\binkley\outbound\018c0001.bsy'
  8. ftpin = 'd:\ftpin\*.*'
  9. tcpbin = 'd:\tcpip\bin'
  10. /* Set to 1 and it becomes a watchdog for FTPFIDO w/o terminating PPP */
  11. WatchDog = 0 
  12. /* Do you have Bink/Max up on the Net? If watchdog = 1 set this to 0 */
  13. binkup = 0
  14. if binkup = 1 then
  15. do
  16. binkflg = 'f:\bbs\binkley\flags\task.03' 
  17. maxflg = 'f:\bbs\max\system\active03.bbs'
  18. end
  19.  
  20. /* End Globals */
  21.  
  22. b = 0
  23. d = 0
  24. abort = 0
  25. thischeck = 0
  26. lastcheck = 0
  27. thistime = 0
  28. lastime = 0
  29. thistimek = 0
  30. lastimek = 0
  31.  
  32. elapsed = time('e')
  33.  
  34. do forever
  35.  Select
  36.    When Stream(ftpflg,'C', 'Query Exists') <>' ' Then
  37.     Do
  38.  
  39.     rc = SysFileTree(ftpin,files.,"F")
  40.  
  41.        if b = 0 then thischeck = files.0 /* First check */
  42.  
  43.        if b = 4 then /* 4 = 10 min. */ 
  44.         do
  45.     lastcheck = files.0
  46.         if thischeck = lastcheck then
  47.          do
  48.         call bbslog "hangup", "Killed FtpFido, no files received"
  49.     'go -k 'ftproc /* process killer. ftproc is the PID */
  50.         abort = 1
  51.         signal Ttyl
  52.          end
  53.         end
  54.  
  55.     if files.0 > 0 then
  56.      do
  57.       if b = 18 | b = 0 then 
  58.        do
  59.        thistime = files.0
  60.        if thistime = lastime then
  61.         do
  62.         call bbslog "hangup", "Killed FtpFido, hung session"
  63.     'go -k 'ftproc /* process killer. ftproc is the PID */
  64.         abort = 1
  65.         signal Ttyl
  66.         end
  67.         else b = 0 
  68.         lastime = thistime
  69.        end
  70.      end
  71.       say 'Must be doing mail....waiting 2.5 mins.'
  72.       Call SysSleep 150
  73.      b = b + 1
  74.     end
  75.  
  76. /*   When Stream(ihubflg,'C', 'Query Exists') <>' ' Then
  77.  *   Do
  78.  *   rc = SysFileTree(kevout,files.,"F")
  79.  *   if c > 2 then
  80.  *       do
  81.  *       abort = 1
  82.  *       signal Ttyl
  83.  *       end
  84.  *   if files.0 > 0 then
  85.  *    do
  86.  *     if d > 7 | d = 0 then 
  87.  *      do
  88.  *      thistime = files.0
  89.  *      if thistimek = lastimek then
  90.  *       do
  91.  *       abort = 1
  92.  *       signal Ttyl
  93.  *       end
  94.  *       else d = 0 
  95.  *       lastimek = thistimek
  96.  *      end
  97.  *    end
  98.  *    else c = c + 1
  99.  *     say 'Kevin must be doing mail....waiting.'
  100.  *     Call SysSleep 300
  101.  *     b = b + 1
  102.  *     d = d + 1
  103.  *   end
  104.  */
  105.  
  106.    When binkup = 1 & Stream(maxflg,'C', 'Query Exists') <>' ' Then
  107.     Do
  108.     elapsed = time('e')
  109.     if elapsed > 3600 then signal Ttyl 
  110.      say 'Someones on the BBS....waiting 5 mins.'
  111.     Call SysSleep 300
  112.      b = b + 1
  113.     end
  114.  
  115.    When binkup = 1 & Stream(binkflg,'C', 'Query Exists') <>' ' Then
  116.     Do
  117.     elapsed = time('e')
  118.     if elapsed > 3600 then signal Ttyl 
  119.      say 'Someones on the mailer....waiting 5 mins.'
  120.     Call SysSleep 300
  121.      b = b + 1
  122.     end
  123.  
  124.    Otherwise
  125.      do
  126.      signal ttyl
  127.      end
  128.  
  129.  end /* Select */
  130. end /* Do Forever */
  131.  
  132. Ttyl:
  133. if abort = 1 then 
  134.  do
  135.  /* del 'f:\binkley\kevin\ihub.bsy > nul: 2>&1' */
  136.  del ftpflg' > nul: 2>&1'
  137.  del hisbsy' > nul: 2>&1'
  138.  end
  139. if watchdog = 0 then
  140. do
  141. say '!Doing the Hangup thing...'
  142.  rc = stream(hangupflg,'C','open write') /* Set hangup flag */
  143. if rc <> 'READY:' Then
  144.   say '!Error creating hangup flagfile.'
  145.  rc = stream(hangupflg,'C','close')
  146. New=Directory(tcpbin)
  147. 'pppkill > nul: 2>&1'
  148. if binkup = 1 then
  149.  do
  150. 'echo > f:\bbs\binkley\flags\btexit01.03'
  151. 'killem vmodem.exe > nul: 2>&1'
  152.  end
  153. /* New=Directory('d:\tcpip\penftpd') */
  154. /* 'penftpd -q' */
  155. end
  156. exit
  157.