home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
set_tcp.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-07-29
|
3KB
|
62 lines
@echo off
rem Rolf Breuning - Email: breu@rog.rwth-aachen.de - 1996/06/05
rem
rem This batch file chooses the correct one of a number of given configurations
rem for TCP/IP LAN access from OS/2 without using the bootp protocol. It may
rem replace setup.cmd in ?:\MPTN\BIN or ?:\TCPIP\BIN or may be inserted in the
rem existing setup.cmd file.
rem The file is called without any argument but calls itself with arguments to
rem realize a subroutine. (Using Rexx did not always work properly when calling
rem the batch file from config.sys)
rem BTW, if you use Warp Connect on a notebook sometimes with and without your
rem PCMCIA network card, you may avoid getting error messages by putting a 'rem'
rem in front of the the \Netware\NWDAEMON.EXE and \IBMCOM\LANMSGEX.EXE
rem (You may start/detach these programs before loggin on into netware or tcpip)
if "%1"=="sub" goto subroutine
:main
rem The main routine. It clears the routing tables, then for each of the
rem possible IP numbers of your computer it calls the subroutine, i.e. itself
rem with 'sub' as the first argument followed by the configuration parameters.
rem
route -fh
arp -f
rem
rem For each of the possible configurations, insert such a line as described below:
rem call %0 sub <IPNumber N> <Netmask N> <Gateway N> <Hostname N> && goto return
rem Examples:
call %0 sub 134.130.137.25 255.255.255.0 134.130.137.250 MERLIN && goto return
call %0 sub 134.130.136.200 255.255.255.0 134.130.136.1 MERLIN2 && goto return
rem
rem [If you want to execute further code depending on the given configuration, replace the
rem 'goto return' by e.g. 'goto configN' or '(call configN.cmd & goto return)']
rem
rem No LAN available, set loopback, close lan0 or use lan0 as loopback
rem ifconfig lo 127.0.0.1
rem ifconfig lan0 down
ifconfig lan0 127.0.0.1 netmask 255.255.255.0
goto return
:subroutine
rem The batch file has called itself with arguments
rem %1 is the string 'sub'
rem %2 = IP number
rem %3 = netmask
rem %4 = gateway
rem %5 = hostname
rem Configure the network adapter and try to ping the gateway
rem If successfull, set route and hostname and return with errorlevel 0
rem Else return with errorlevel 1
rem
ifconfig lan0 %2 netmask %3
echo ping to %4
ping %4 56 1 | find /I " 0%% packet loss" >nul || goto return
echo ping ok: IP=%2, Hostname=%5
route add default %4 1
set hostname=%5
rem Return label, must be the last entry of the batch file
:return