home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / setuptcp.cmd < prev    next >
OS/2 REXX Batch file  |  1996-06-20  |  3KB  |  62 lines

  1. @echo off
  2. rem Rolf Breuning  -  Email: breu@rog.rwth-aachen.de  -  1996/06/05
  3. rem 
  4. rem This batch file chooses the correct one of a number of given configurations
  5. rem for TCP/IP LAN access from OS/2 without using the bootp protocol. It may
  6. rem replace setup.cmd in ?:\MPTN\BIN or ?:\TCPIP\BIN or may be inserted in the
  7. rem existing setup.cmd file. 
  8. rem The file is called without any argument but calls itself with arguments to
  9. rem realize a subroutine. (Using Rexx did not always work properly when calling
  10. rem the batch file from config.sys)
  11. rem BTW, if you use Warp Connect on a notebook sometimes with and without your
  12. rem PCMCIA network card, you may avoid getting error messages by putting a 'rem'
  13. rem in front of the the \Netware\NWDAEMON.EXE and \IBMCOM\LANMSGEX.EXE
  14. rem (You may start/detach these programs before loggin on into netware or tcpip)
  15. if "%1"=="sub" goto subroutine
  16.  
  17. :main
  18. rem The main routine. It clears the routing tables, then for each of the
  19. rem possible IP numbers of your computer it calls the subroutine, i.e. itself
  20. rem with 'sub' as the first argument followed by the configuration parameters.
  21. rem 
  22. route -fh
  23. arp -f
  24. rem
  25. rem For each of the possible configurations, insert such a line as described below:
  26. rem call %0 sub <IPNumber N> <Netmask N> <Gateway N> <Hostname N> && goto return
  27. rem Examples:
  28. call %0 sub 134.130.137.25  255.255.255.0 134.130.137.250 MERLIN  && goto return
  29. call %0 sub 134.130.136.200 255.255.255.0 134.130.136.1   MERLIN2 && goto return
  30. rem
  31. rem  [If you want to execute further code depending on the given configuration, replace the
  32. rem   'goto return' by e.g. 'goto configN' or '(call configN.cmd & goto return)']
  33. rem
  34. rem No LAN available, set loopback, close lan0 or use lan0 as loopback
  35. rem ifconfig lo 127.0.0.1
  36. rem ifconfig lan0 down
  37. ifconfig lan0 127.0.0.1 netmask 255.255.255.0
  38. goto return
  39.  
  40.  
  41. :subroutine
  42. rem The batch file has called itself with arguments
  43. rem   %1 is the string 'sub'
  44. rem   %2 = IP number
  45. rem   %3 = netmask
  46. rem   %4 = gateway
  47. rem   %5 = hostname
  48. rem Configure the network adapter and try to ping the gateway
  49. rem If successfull, set route and hostname and return with errorlevel 0
  50. rem Else return with errorlevel 1
  51. rem
  52. ifconfig lan0 %2 netmask %3
  53. echo ping to %4
  54. ping %4 56 1 | find /I " 0%% packet loss" >nul || goto return
  55. echo   ping ok: IP=%2, Hostname=%5
  56. route add default %4 1
  57. set hostname=%5
  58.  
  59.  
  60. rem Return label, must be the last entry of the batch file
  61. :return
  62.