home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / usnetcmd.zip / USNET.CMD
OS/2 REXX Batch file  |  1995-03-12  |  16KB  |  393 lines

  1. <<<<<<<<<<<< OS/2 WARP 3.0 USNET INTERNET HOWTO V 1.0.1  1/11/95 >>>>>>>>>>>>>>
  2. Authored by Richard E. Esposito (esposito@us.net)
  3. Please send any comments to support@us.net as I do not have time to support
  4. this code.  I am providing it AS IS.
  5. .............................................................................
  6.  
  7. In my opinion, nothing I've seen comes close to the software provided
  8. with OS/2 WARP 3.0 for accessing the INTERNET.  I spent many hours
  9. coming up with the following configuration which seems to work so far.
  10. Information was delved from IBM's OS/2 Online Book Collection CD-ROM
  11. and the Linux NET-2 HOWTO by Terry Dawson (terryd@extro.ucc.su.oz.au)
  12. and Matt Welsh (mdw@sunsite.unc.edu)
  13.  
  14. Please feel free to experiment with it.  Send any improvements to
  15. support@us.net whom I assume will maintain this document and code.
  16.  
  17. This setup does not require a dedicated IP address as it dynamically creates
  18. the hosts file after achieving a modem connection.
  19.  
  20. NOTE: Sometimes the Ulti-mail/2 "In-basket" kicks off prematurely and reports
  21.       "In-basket-refreshed failed!".  If this happens, close that information
  22.       window and click the pull-down "In-basket/Refresh" to recover when disk
  23.       activity settles down.
  24.  
  25. The setup requires 3 files:
  26.  
  27. 1) c:\tcpip\etc\hosts.tcp
  28. 2) c:\tcp\etc\networks
  29. 3) c:\tcpip\bin\usnet.cmd
  30.  
  31. plus entries for "Dial Other Internet Providers" (Add/Modify Provider).
  32.  
  33. Be sure to substitute your user-ID and password for mine ( esposito
  34. and <password> ) throughout.
  35.  
  36. Once this is set up and running, you can use "Retrieve Software Updates"
  37. to get the "Web Explorer" Software.
  38.  
  39. GOOD LUCK!
  40.  
  41. c:\tcpip\etc\hosts.tcp
  42. ========================================================================
  43. 127.0.0.1          localhost
  44. 198.240.64.2       usnet.us.net nameserver
  45. 198.240.64.3       ns.us.net ftp.us.net
  46. 198.240.72.4       laurel.us.net
  47. ========================================================================
  48.  
  49. c:\tcp\etc\networks
  50. ========================================================================
  51. default  0.0.0.0   # default route - mandatory
  52. loopnet  127.0.0.0 # loopback network - mandatory
  53. usnet64  198.240.64.0
  54. usnet72  198.240.72.0
  55. ========================================================================
  56.  
  57. Entries for "Dial Other Internet Providers" (Add/Modify Provider)
  58. ========================================================================
  59. *Provider name: US Net
  60.  Login ID: esposito
  61.  Password: <my password>
  62. *Nickname: Esposito
  63. *Phone number: 792-8817
  64.  Login script: usenet.cmd atdt792-8817 esposito <my password>
  65.  Connection type: SLIP
  66.  Minutes to wait before hangup: 5
  67. ------------------------------------------------------------------------
  68. *Your IP address: (grayed out)
  69. *Destination IP address: (grayed out)
  70.  Netmask: (grayed out)
  71. *MTU size: 1006
  72.  VJ Compression: (checked)
  73. *Domain Nameserver: 198.240.64.2
  74.  Your Host Name: esposito@us.net
  75. *Your Domain name: us.net
  76. ------------------------------------------------------------------------
  77.  News Server: news.us.net
  78.  Gopher Server: boombox.micro.umn.edu
  79.  WWW Server: http://www.ncsa.uiuc.edu
  80.  POP Mail Server: mail.us.net
  81.  Reply Domain: us.net
  82.  Reply (mail) ID: esposito@us.net
  83.  POP Login ID: esposito
  84.  POP Password: <my password>
  85. ------------------------------------------------------------------------
  86.  Modem Type: (grayed out)
  87.  Com Port: com2
  88.  Speed (Baud): 57600
  89.  Data Bits: 8
  90.  Parity: NONE
  91.  Dial Prefix: (grayed out)
  92.  Initialization String 1: (grayed out ATDT)
  93.  Initialization String 2: (grayed out ~AT X4 E0 V1)
  94.  Call Waiting Disable: (grayed out)
  95.  Call Waiting Disable Sequence: (grayed out *70)
  96. ========================================================================
  97.  
  98. c:\tcpip\bin\usnet.cmd command file
  99. ==============================================================================
  100. /*--------------------------------------------------------------------------*/
  101. /*                                                                          */
  102. /*        OS/2 2.1 / WARP REX Driver for IBM TCP/IP version 2.1 / REE       */
  103. /*            (BOOTP Version - Does not need dedicated IP address)          */
  104. /*                                                                          */
  105. /*        NOTE: You must preinstall the "C:\tcpip\etc\host.tcp" and         */
  106. /*              "C:\tcpip\etc\networks" files.                              */
  107. /*                                                                          */
  108. /*                                USNET.CMD                                 */
  109. /*                                                                          */
  110. /*            ..................................................            */
  111. /*                                                                          */
  112. /* Attachment script for dialing into a USNET terminal                      */
  113. /* server in order to establish a SLIP connection.                          */
  114. /*                                                                          */
  115. /* The script parameters specify the command to send to the modem to dial   */
  116. /* the remote site and the UserID/Password combination to use to log into   */
  117. /* the terminal server.                                                     */
  118. /*                                                                          */
  119. /* For example, the following should be used with SlipPM's Dial Other       */
  120. /* Internet Providers settings book:                                        */
  121. /*                                                                          */
  122. /*       Login Script: usnet.cmd ATDT792-8817 LoginID Password              */
  123. /*                                                                          */
  124. /* which would then feeds the "ATDT792-8817" command to the modem, followed */
  125. /* by the Login ID and Password once the connection is established.         */
  126. /*                                                                          */
  127. /*            - - - - - - - - - - - - - - - - - - - - - - - - -             */
  128. /*                                                                          */
  129. /* When the script runs, it is automatically passed the interface name for  */
  130. /* the interface it is running on as the first argument, followed by the    */
  131. /* user arguments.                                                          */
  132. /*                                                                          */
  133. /* The script sends the dial string to the modem and then logs into the     */
  134. /* terminal server using the username/password.  It then issues the SLIP    */
  135. /* command to start SLIP, and parses the resulting output to determine the  */
  136. /* appropriate addresses to use.  Lastly, it issues ifconfig and route      */
  137. /* commands to configure the OS/2 system appropriately.  Note that the      */
  138. /* configuration assumes a class C netmask for the SLIP interface.          */
  139. /*                                                                          */
  140. /*--------------------------------------------------------------------------*/
  141.  
  142. parse arg interface , dialcmd username password
  143.  
  144. /*--------------------------------------------------------------------------*/
  145. /*                   Initialization and Main Script Code                    */
  146. /*--------------------------------------------------------------------------*/
  147.  
  148. /* Set some definitions for easier COM strings */
  149. cr='0d'x
  150. crlf='0d0a'x
  151.  
  152. say ' '
  153. say 'USNET - US Net Internet Gateway SLIP Connection Script ',
  154.     '(interface' interface')'
  155.  
  156. /* Prompt for missing information */
  157. if dialcmd = '' | dialcmd = '*' then do
  158.    call charout , 'Dial Command: '
  159.    parse pull dialcmd
  160. end
  161. else do
  162.    say 'Dial Command: ' dialcmd
  163. end
  164.  
  165. if username = '' | username = '*' then do
  166.    call charout , 'User Name: '
  167.    parse pull username
  168. end
  169. else do
  170.    say 'User:' username
  171. end
  172.  
  173. if password = '' | password = '*' then do
  174.    call charout , 'Password: '
  175.    password = readpass()
  176. end
  177.  
  178. /* Flush any stuff left over from previous COM activity */
  179. call flush_receive
  180.  
  181. /* Reset the modem here */
  182. /* You may need to customize this for your modem make and model */
  183. call lineout , 'Reset modem...'
  184.  
  185. /* This setup string is for the ZOOM FAX14.4 modem */
  186. call send 'AT&FX4&C1&D2&K3&Q5&R0S11=55S95=35' || cr
  187.  
  188. /* The following is for generic Hayes compatible modems */
  189. /* call send 'ATZ&C1&D2' || cr */
  190. /* call send 'ATE1Q0V1X4' || cr */
  191.  
  192. call waitfor 'OK', 5 ; call flush_receive 'echo'
  193.  if RC = 1 then do
  194.     call lineout , 'Modem not resetting... Trying again'
  195.     call send '+++'
  196.     call waitfor 'OK'
  197.     call send 'ATHZ' || cr
  198.     call waitfor 'OK', 3
  199.   end
  200.  
  201. /* Send Dial instructions for the remote server */
  202. call charout , 'Now Dialing...'
  203.  
  204. /* Wait for USNET connection */
  205. call send dialcmd || cr
  206. call waitfor 'CONNECT' ; call waitfor crlf
  207.  
  208. /* Handle login.  Wait for standard strings, and then flush anything */
  209. /* else to take care of trailing spaces, etc..                       */
  210. /* call send cr */
  211. call waitfor 'login:' ; call flush_receive 'echo'
  212. call send username || cr
  213. call waitfor 'Password:' ; call flush_receive 'echo'
  214. call send password || cr
  215. call waitfor 'usnet> '; call flush_receive 'echo'
  216. call send 'slip' || cr
  217.  
  218. /* Parse the results of the SLIP command to determine our address.   */
  219. /* We use the "waitfor_buffer" variable from the waitfor routine     */
  220. /* to parse the stuff we get from US Net after waiting for an        */
  221. /* appropriate point in the data stream.                             */
  222.  
  223. call waitfor 'abled'
  224. parse var waitfor_buffer .  'IP address is IP=' a '.' b '.' c '.' d '.' .
  225. os2_address = a||'.'||b||'.'||c||'.'||d
  226. /* Flush anything else beyond 14 characters */
  227. call flush_receive 'echo'
  228. os2_address = DELSTR(os2_address, 14)
  229.  
  230. /* Specify US Net address */
  231. usnet_address = '198.240.64.2'
  232.  
  233. /* Create a valid hosts file including dynamic IP address */
  234. /* Must match YOUR HOST NAME in Dial Other Internet Providers folder */
  235. host_name = 'esposito@us.net'
  236.  
  237. /* Initialize hosts file sans the local entry */
  238. say 'creating hosts file'
  239.  
  240. 'COPY c:\tcpip\etc\hosts.tcp c:\tcpip\etc\hosts'
  241.  
  242. /* add local entry to hosts file */
  243. say 'adding local IP entry to hosts file'
  244. line_out = os2_address||' '||host_name
  245. hosts = 'c:\tcpip\etc\hosts'
  246. lineout(hosts, line_out)
  247.  
  248. say 'testing...'
  249.  
  250. /* Attach the loopback device */
  251. 'ifconfig lo 127.0.0.1'
  252. 'route add 127.0.0.1 1'
  253. /* end loopback definition */
  254.  
  255. 'hostname -S esposito.us.net'
  256.  
  257. /* Now configure this host for the appropriate address, */
  258. /* and for a default route through the US Net.          */
  259.  
  260. say 'SLIP Connection Established'
  261.  
  262. say 'Configuring local address =' os2_address ', US Net =' usnet_address
  263. 'ifconfig sl0 ' os2_address usnet_address ' up netmask 255.255.0.0'
  264. 'ifconfig sl0 ' os2_address ' pointopoint ' usnet_address
  265.  
  266. say 'Routing default =' usnet_address
  267. 'route add default ' usnet_address ' 1'
  268.  
  269. /* All done */
  270. exit 0
  271.  
  272. /*--------------------------------------------------------------------------*/
  273. /*                            send ( sendstring)                            */
  274. /*..........................................................................*/
  275. /*                                                                          */
  276. /* Routine to send a character string off to the modem.                     */
  277. /*                                                                          */
  278. /*--------------------------------------------------------------------------*/
  279.  
  280. send:
  281.  
  282.    parse arg sendstring
  283.    call slip_com_output interface , sendstring
  284.  
  285.    return
  286.  
  287. /*--------------------------------------------------------------------------*/
  288. /*                    waitfor ( waitstring , [timeout] )                    */
  289. /*..........................................................................*/
  290. /*                                                                          */
  291. /* Waits for the supplied string to show up in the COM input.  All input    */
  292. /* from the time this function is called until the string shows up in the   */
  293. /* input is accumulated in the "waitfor_buffer" variable.                   */
  294. /*                                                                          */
  295. /* If timeout is specified, it says how long to wait if data stops showing  */
  296. /* up on the COM port (in seconds).                                         */
  297. /*                                                                          */
  298. /*--------------------------------------------------------------------------*/
  299.  
  300. waitfor:
  301.  
  302.    parse arg waitstring , timeout
  303.  
  304.    if timeout = '' then
  305.      timeout = 5000    /* L O N G   delay if not specified */
  306.    waitfor_buffer = '' ; done = -1; curpos = 1
  307.    ORI_TIME=TIME('E')
  308.  
  309.    if (remain_buffer = 'REMAIN_BUFFER') then do
  310.       remain_buffer = ''
  311.    end
  312.  
  313.    do while (done = -1)
  314.       if (remain_buffer \= '') then do
  315.          line = remain_buffer
  316.          remain_buffer = ''
  317.        end
  318.        else do
  319.          line = slip_com_input(interface,,10)
  320.       end
  321.       waitfor_buffer = waitfor_buffer || line
  322.       index = pos(waitstring,waitfor_buffer)
  323.       if (index > 0) then do
  324.          remain_buffer = substr(waitfor_buffer,index+length(waitstring))
  325.          waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
  326.          done = 0
  327.       end
  328.       call charout , substr(waitfor_buffer,curpos)
  329.       curpos = length(waitfor_buffer)+1
  330.       if ((done \= 0) & (TIME('E')>timeout)) then do
  331.         call lineout , ' WAITFOR: timed out '
  332.         done = 1
  333.        end
  334.    end
  335.    timeout=0
  336.    RC=done
  337.  return RC
  338.  
  339. /*--------------------------------------------------------------------------*/
  340. /*                               readpass ()                                */
  341. /*..........................................................................*/
  342. /*                                                                          */
  343. /* Routine used to read a password from the user without echoing the        */
  344. /* password to the screen.                                                  */
  345. /*                                                                          */
  346. /*--------------------------------------------------------------------------*/
  347.  
  348. readpass:
  349.  
  350.   answer = ''
  351.   do until key = cr
  352.       key = slip_getch()
  353.     if key \= cr then do
  354.       answer = answer || key
  355.     end
  356.   end
  357.   say ' '
  358.   return answer
  359.  
  360. /*--------------------------------------------------------------------------*/
  361. /*                             flush_receive ()                             */
  362. /*..........................................................................*/
  363. /*                                                                          */
  364. /* Routine to flush any pending characters to be read from the COM port.    */
  365. /* Reads everything it can until nothing new shows up for 100ms, at which   */
  366. /* point it returns.                                                        */
  367. /*                                                                          */
  368. /* The optional echo argument, if 1, says to echo flushed information.      */
  369. /*                                                                          */
  370. /*--------------------------------------------------------------------------*/
  371.  
  372. flush_receive:
  373.    parse arg echo
  374.  
  375.    /* If echoing the flush - take care of waitfor remaining buffer */
  376.    if (echo \= '') & (length(remain_buffer) > 0) then do
  377.       call charout , remain_buffer
  378.       remain_buffer = ''
  379.    end
  380.  
  381.    /* Eat anything left in the modem or COM buffers */
  382.    /* Stop when nothing new appears for 100ms.      */
  383.  
  384.    do until line = ''
  385.      line = slip_com_input(interface,,100)
  386.      if echo \= '' then
  387.         call charout , line
  388.    end
  389.  
  390.    return
  391. ============================================================================
  392. <<<<<<<< END OF HOWTO DOCUMENT >>>>>>>>>>>
  393.