home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / comms_networking / netreader / !NetReader / Misc / !CallCIX next >
Encoding:
Text File  |  1995-05-03  |  7.1 KB  |  286 lines

  1. ; An ArcTerm7 script to call CIX and download new mail and messages.
  2. ; written by Paul Vigay - (C)1993
  3. ; This version dated 3rd May 1995
  4. ;
  5. ; This dials the CIX in London at 19200/19200 (v32bis) and downloads 
  6. ; all new messages to any conferences you are a member of. It then
  7. ; downloads any private mail you may have.
  8. ; The two files are renamed as CIXmessages and CIXmail respectively.
  9. ; Lastly, if you have a reply file called MailToCIX, it will upload it for
  10. ; you.
  11. ; It can also go into Newnet and download any new messages there.
  12.  
  13. main ()
  14. {
  15.   ; Change the following two lines depending upon which directories you
  16.   ; want the downloaded/uploaded files to go in.
  17.   string downloaddir[80]="SCSI::SCSIDisc4.$.Applicats.Comms.Up/Dnloads"
  18.   string uploaddir[80]="SCSI::SCSIDisc4.$.Applicats.Comms.Up/Dnloads"
  19.   
  20.   string newname[80]=""
  21.   string CSI[2]=$chr(27)+"[",red[5]=CSI+"31m",white[5]=CSI+"37m",cyan[5]=CSI+"36m",yellow[5]=CSI+"33m"
  22.   integer flag,busy,line,loop
  23.   openwindow()
  24.  
  25.   ; The following lines set the speed of your communication. This may need to
  26.   ; be changed, depending upon which modem you have.
  27.   port_txspeed(19200)
  28.   port_rxspeed(19200)
  29.   
  30.   $port_wordformat("8N1")
  31.   set(filter,on)
  32.   modem_errorcontrol("mnp5")
  33.   set(terminal,ansi)
  34.   check_files()
  35.   busy=1
  36.   if (flag==0)
  37.     {
  38.     repeat
  39.     {
  40.       line=2
  41.       prints newline+cyan+"Calling CIX - Please wait...."+newline+white
  42.       line=modem_dial("0181 390 1255",1)
  43.  
  44.       ; Wait a second for it to wake up!
  45.       pause(100)
  46.  
  47.       if (line<>2)
  48.       {
  49.   
  50.       ; Wait up to 30 seconds for login prompt
  51.       if (waitfor("login:",3000))
  52.         {
  53.         prints newline+red+"Call failed (no login prompt)"+newline+white
  54.         modem_disconnect()
  55.         return
  56.         }
  57.       type "qix"+cr
  58.       ; Wait 60 secs for username prompt
  59.       if (waitfor("new user)",6000))
  60.         {
  61.         prints newline+red+"Call failed (no username prompt)"+newline+white
  62.         modem_disconnect()
  63.         return
  64.         }
  65.       ; insert your user 'nickname' in the line below!
  66.       type "nickname"+cr
  67.       ; Wait up to 20 seconds for password prompt
  68.       if (waitfor("Password:",2000))
  69.         {
  70.         prints newline+red+"Call failed (no password prompt)"+newline+white
  71.         modem_disconnect()
  72.         return
  73.         }
  74.       ; insert your user 'password' in the line below! (check case)
  75.       type "PASSWORD"+cr
  76.       ; ok respond to any 'More ?' messages.
  77.       whenever(1,"More ?",anykey)
  78.       ; ok, hang up immediately the Goodbye message is displayed.
  79.       whenever(1,"!HANGUP NOW!!!",hangup)
  80.       waitfor("Main")
  81.       ; ******** Now grab any new conference messages *******
  82.       grab_messages()
  83.       ; ******** Now grab any new personal mail messages *******
  84.       grab_mail()
  85.       ; now upload any mail we may have
  86.       send_mail()
  87.       ; now upload any private mail we may have
  88.       send_pmail()
  89.       ; Now whiz to UseNet and grab any new messages.
  90.       grab_newsnet()
  91.       send_newsnet()     
  92.       prints newline+red+"OK. Script ended. It's up to you now!!!"+newline+white
  93.       busy=0
  94.       ;type "bye"+cr
  95.       ;waitfor("!!!HANGUP NOW!!!")
  96.       ;modem_disconnect()
  97.       whenever(1,"",off)
  98.       }
  99.     if (busy==1)
  100.       {
  101.       loop=10
  102.       prints newline+yellow+"About to redial. "
  103.       repeat
  104.         {
  105.         print loop
  106.         prints "  "
  107.         loop=loop-1
  108.         pause (100)
  109.         }
  110.       until(loop=0)
  111.       }
  112.     }
  113.     until(busy==0)
  114.     }
  115. }
  116.  
  117. anykey ()
  118.   {
  119.     type cr
  120.   }
  121.  
  122. hangup ()
  123.   {
  124.     modem_disconnect()
  125.   }
  126.   
  127. grab_messages ()
  128. {
  129.   type "file read all"+cr
  130.   waitfor("Scratchpad")
  131.   if(waitfor("is 69 bytes.",50))
  132.     {
  133.     ;waitfor("Main")
  134.     type "arcscratch"+cr
  135.     waitfor("Main")
  136.     type "download"+cr
  137.     download(zmodem,downloaddir)
  138.     ; Rename downloaded scratchpad so it won't get overwritten,
  139.     ; and set it to an ARC filetype.
  140.     newname=downloaddir+".CIXmsgs"
  141.     oscli("Rename "+downloaddir+".Scratchpad "+newname)
  142.     oscli("SetType "+newname+" ddc")
  143.     waitfor("OK to delete the downloaded scratchpad-file?",500)
  144.     type "Y"+cr
  145.     }
  146.   waitfor("Main")
  147. }
  148.  
  149. grab_mail ()
  150. {
  151.   type "mail"+cr
  152.   waitfor("Mail")
  153.   type "file all"+cr
  154.   waitfor("Scratchpad")
  155.   if(waitfor("is 0 bytes",50))
  156.     {
  157.     ;waitfor("Mail")
  158.     type "arcscratch"+cr
  159.     waitfor("Mail")
  160.     type "download"+cr
  161.     download(zmodem,downloaddir)
  162.     ; Rename downloaded scratchpad so it won't get overwritten,
  163.     ; and set it to an ARC filetype.
  164.     newname=downloaddir+".CMl"
  165.     oscli("Rename "+downloaddir+".Scratchpad "+newname)
  166.     oscli("SetType "+newname+" ddc")
  167.     waitfor("OK to delete the downloaded scratchpad-file?",500)
  168.     type "Y"+cr
  169.     }
  170.   waitfor("Mail")
  171.   type "quit"+cr
  172.   waitfor("Main")
  173. }
  174.  
  175. send_mail ()
  176. {
  177.   string filename[80]=uploaddir+".MailToCIX"
  178.   if (file_openin(0,filename)!=0)
  179.     {
  180.     string line[80]
  181.     integer starttime
  182.     ; File exists: close it and upload
  183.     file_close(0)
  184.     batch_clear()
  185.     batch_add(filename)
  186.     type "upload"+cr
  187.     waitfor("B0100")
  188.     upload(zmodem)
  189.     waitfor("Main:")
  190.     type "scput script"+cr
  191.     waitfor("Main:")
  192.     type "script"+cr
  193.     waitfor("Main:")
  194.     oscli("Copy "+filename+" "+uploaddir+".Old.OldToCIX ~c~vfd")
  195.     }
  196.  
  197. }
  198.  
  199. send_pmail ()
  200. {
  201.   string filename[80]=uploaddir+".MailToCMl"
  202.   if (file_openin(0,filename)!=0)
  203.     {
  204.     string line[80]
  205.     integer starttime
  206.     ; File exists: close it and upload
  207.     file_close(0)
  208.     batch_clear()
  209.     batch_add(filename)
  210.     type "upload"+cr
  211.     waitfor("B0100")
  212.     upload(zmodem)
  213.     waitfor("Main:")
  214.     type "scput script"+cr
  215.     waitfor("Main:")
  216.     type "script"+cr
  217.     waitfor("Main:")
  218.     oscli("Copy "+filename+" "+uploaddir+".Old.OldToCMl ~c~vfd")
  219.     }
  220.  
  221. }
  222.  
  223. check_files ()
  224. {
  225.   ; the following procedure will ensure that the script is only run
  226.   ; if the three files CIXmsgs, CIXmail and Scratchpad do NOT exist.
  227.   flag=0
  228.   if (file_openin(0,downloaddir+".ScratchPa")<>0)
  229.     {
  230.     prints red+"File ScratchPad already exists - Script aborted!"+newline+white
  231.     flag=1
  232.     }
  233.   file_close(0)
  234.   if (file_openin(0,downloaddir+".CIXmsgs")<>0)
  235.     {
  236.     prints red+"File CIXmsgs already exists - Script aborted!"+newline+white
  237.     flag=1
  238.     }
  239.   file_close(0)
  240.   if (file_openin(0,downloaddir+".CIXmail")<>0)
  241.     {
  242.     prints red+"File CIXmail already exists - Script aborted!"+newline+white
  243.     flag=1
  244.     }
  245.   file_close(0)
  246. }
  247.  
  248. grab_newsnet ()
  249. {
  250.   type "go newsnet"+cr
  251.   waitfor("Newsnet:")
  252.   type "batch all endbatch"+cr
  253.   waitfor("Newsnet:")
  254.   type "arcbatch"+cr
  255.   waitfor("Newsnet:")
  256.   type "download messages"+cr
  257.   download(zmodem,downloaddir)
  258.   ;Rename downloaded scratchpad so it won't get overwritten,
  259.   ;and set it to an ARC filetype.
  260.   newname=downloaddir+".UseNet"
  261.   oscli("Rename "+downloaddir+".Scratchpad "+newname)
  262.   oscli("SetType "+newname+" ddc")  
  263.   waitfor("Newsnet:")
  264. }
  265.  
  266. send_newsnet ()
  267. {
  268.   string filename[80]=uploaddir+".MailToNews"
  269.   if (file_openin(0,filename)!=0)
  270.     {
  271.     string line[80]
  272.     integer starttime
  273.     ; File exists: close it and upload
  274.     file_close(0)
  275.     batch_clear()
  276.     batch_add(filename)
  277.     type "upload messages"+cr
  278.     waitfor("B0100")
  279.     upload(zmodem)
  280.     waitfor("Newsnet:")
  281.     type "quit"+cr
  282.     waitfor("Main:")
  283.     oscli("Copy "+filename+" "+uploaddir+".Old.OldToNews ~c~vfd")
  284.     }
  285. }
  286.