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

  1. /* Moveftp.cmd */
  2. '@echo off'
  3. fidohold3 = 'f:\binkley\os2net.051\03d40000.hlo'
  4. fidohold4 = 'f:\binkley\ibmnet.028\1112025c.hlo'
  5. fidohold5 = 'f:\binkley\os2net.051\008c000f.hlo'
  6. bbs_log = 'f:\bbs\logs\ftpmove.log'
  7.  
  8. esc = D2C(27)
  9. ansi_red = esc || '[1;31m' 
  10. ansi_yellow = esc || '[1;33m' 
  11. ansi_normal = esc || '[0m'
  12.  
  13.  
  14. IF Stream(fidohold3,'C', 'Query Exists') <>' ' Then
  15.   Do
  16.   moveto = 'f:\ftpmail\81.980.0\out'
  17.   holdfile = 'f:\binkley\os2net.051\03d40000.hlo'
  18.   fidobsy = 'f:\binkley\os2net.051\03d40000.bsy'
  19.   ihubusy = 'f:\ftpmail\81.980.0\*.bsy'
  20.   trial_count = 0
  21.   say ansi_yellow 'Moving mail for 81:980/0...' ansi_normal
  22.   call movelog date('N') Time('N') ' 81:980/0'  'Moving mail for 81:980/0 to 'moveto
  23.   call makebsy
  24.   end /* Do */
  25.    else say ansi_red 'Nothing to move!' ansi_normal
  26.  
  27. IF Stream(fidohold4,'C', 'Query Exists') <>' ' Then
  28.   Do
  29.   moveto = 'f:\ftpmail\81.140.15\out'
  30.   holdfile = 'f:\binkley\ibmnet.028\1112025c.hlo'
  31.   fidobsy = 'f:\binkley\ibmnet.028\1112025c.bsy'
  32.   ihubusy = 'f:\ftpmail\81.140.15\*.bsy'
  33.   trial_count = 0
  34.   say ansi_yellow 'Moving mail for 40:4370/604...' ansi_normal
  35.   call movelog date('N') Time('N') ' 40:4370/604'  'Moving mail for 40:4370/604 to 'moveto
  36.   call makebsy
  37.   end /* Do */
  38.    else say ansi_red 'Nothing to move!' ansi_normal
  39.  
  40. IF Stream(fidohold5,'C', 'Query Exists') <>' ' Then
  41.   Do
  42.   moveto = 'f:\ftpmail\81.140.15\out'
  43.   holdfile = 'f:\binkley\os2net.051\008c000f.hlo'
  44.   fidobsy = 'f:\binkley\os2net.051\008c000f.bsy'
  45.   ihubusy = 'f:\ftpmail\81.140.15\*.bsy'
  46.   trial_count = 0
  47.   say ansi_yellow 'Moving mail for 81:140/15...' ansi_normal
  48.   call movelog date('N') Time('N') ' 81:140/15'  'Moving mail for 81:140/15 to 'moveto
  49.   call makebsy
  50.   end /* Do */
  51.    else say ansi_red 'Nothing to move!' ansi_normal
  52.  
  53. /* Inbound */
  54.  
  55.   IF Stream('f:\ftpmail\81.980.0\in\*.*','C', 'Query Exists') <>' ' Then
  56.   Do
  57.   New = Directory('f:\ftpmail\81.980.0\in')
  58.   'move *.* \binkley\inbound > nul: 2>&1'
  59.   end 
  60.  
  61.   IF Stream('f:\ftpmail\81.140.15\in\*.*','C', 'Query Exists') <>' ' Then
  62.   Do
  63.   New = Directory('f:\ftpmail\81.140.15\in')
  64.   'move *.* \binkley\inbound > nul: 2>&1'
  65.   end 
  66.  
  67. exit
  68.  
  69. Makebsy:
  70.  
  71.    IF Stream(ihubusy,'C', 'Query Exists') <>' ' Then
  72.       Do
  73.       say ansi_red 'Not this time!!!' ansi_normal
  74.       Return(0)
  75.       end
  76.  
  77. do until (trial_count > 3)
  78.  
  79.     trial_count = trial_count + 1
  80.     if trial_count < 4
  81.     then
  82.     do
  83.    IF Stream(fidobsy,'C', 'Query Exists') <>' ' Then
  84.       Do
  85.       say ansi_red '!Node is busy - waiting.' ansi_normal
  86.       call SysSleep 60            /* sleep 60 seconds and wait */
  87.       end
  88.      else
  89.         do
  90.         'echo > 'fidobsy
  91.       trial_count = 4
  92.         Call movee
  93.         end
  94.     end
  95.   else
  96.       do
  97.       Say ansi_yellow 'Tired of waiting for busy flag...' ansi_normal
  98.       call movelog date('N') Time('N') ' Makebsy'  'Timed out waiting for busyflag!'
  99.       Return(0)
  100.       end
  101. end /* Do until */
  102. Return(0)
  103.  
  104. Movee:
  105.  
  106.   New = Directory(moveto)
  107.  
  108.    do until LINES(holdfile) = 0
  109.     line = LINEIN(holdfile)
  110.  
  111.     if line > "" then do
  112.     Select
  113.      When Pos('^', line) = 1 then
  114.       Do
  115.      fullname = strip(line,l,'^')
  116.       IF Stream(fullname,'C', 'Query Exists') <>' ' Then
  117.        Do
  118.       'copy 'fullname
  119.       'del 'fullname
  120.        call movelog date('N') Time('N') 'Moving 'fullname
  121.        end
  122.       end
  123.      When Pos('#', line) = 1 & word(file.1,3) <> 0 then
  124.        Do
  125.      fullname = strip(line,l,'#')
  126.       IF Stream(fullname,'C', 'Query Exists') <>' ' Then
  127.         Do
  128.        call movelog date('N') Time('N') ' Copy/Trunc 'fullname
  129.       'copy 'fullname
  130.        rc=SysFileDelete(fullname)
  131.         IF rc <> 0 Then
  132.           do
  133.           say ansi_red '!Error del/truncating 'fullname ansi_normal
  134.           rc = lineout(logfile,'!Error del/truncating 'fullname
  135.           end
  136.            else do
  137.               rc = stream(fullname,'C','open write')
  138.               if rc <> 'READY:' Then
  139.                 Do
  140.                 say ansi_red '!Error recreating 'fullname ansi_normal
  141.                 rc = lineout(logfile,'!Error recreating 'fullname)
  142.                 end 
  143.               call stream fullname, 'C', 'close'
  144.             end
  145.         end
  146.        end
  147.     otherwise
  148.        Do
  149.       IF Stream(line,'C', 'Query Exists') <>' ' Then
  150.         Do
  151.        call movelog date('N') Time('N') ' Copying 'line
  152.       'copy 'line
  153.         end
  154.        end
  155.     end /* Select */
  156.      end
  157.    end /* Do Until */
  158.    rc = stream(holdfile,'C','close')
  159.         'del 'holdfile '> nul: 2>&1'
  160.         'del 'fidobsy '> nul: 2>&1'
  161.        IF rc <> 0 Then
  162.        Do
  163.        say ansi_red '!Error deleting 'fidobsy ansi_normal
  164.        call movelog date('N') Time('N') ' Movee'  '!Error deleting 'fidobsy
  165.        end
  166. Return(0)
  167.  
  168. Movelog:
  169.    parse arg dt tm wh fr jb
  170.    call Lineout bbs_log ,dt tm wh fr jb
  171.    rc = stream(bbs_log,'c','close')
  172. Return(0)
  173.