WAI
I've cracked it!!!!
My slightly amended script
--------------
#!/bin/bash
# Auther @Wai Ming Pang Date 22 Feb 2003
#########################################
## Originally written for RedHat
## Adapted by Dave Spagnol for Mandrake 9.0 28 Feb 2003
#########################################
## A script that reconnects your internet connection should the
## mac address gets taken by other processes
##
## You will need to change the mac address and
## interface name before you start this script as root
## Run the script > reloadifusb &
##
## When you do fail to connect to the web please allow time for the
## script to kick in.
##
## The author accepts no responsible for the use of this script.
## change this to your mac address (hardware address, physical address)
## check with ifconfig -a or (ipconfig /all in windows)
macAddress=00: D0:59:xx:xx:xx (omit space between : and D - included to prevent smilie)
## your interface name usually eth0 or eth1
usbif=eth1
reset=0
while true
do
count=`ifconfig $usbif | grep "00:00:00:00" | wc -l`
if [ $count -gt 0 ]
then
echo Resetting $usbif for $reset times
ifconfig $usbif down
ifconfig $usbif hw ether $macAddress
ifconfig $usbif up
ifdown $usbif
ifup $usbif
echo Hopefully $usbif up by now!
reset=$(( $reset + 1 ))
fi
sleep 10
done
---------------
It works because I had it running in the CTRL-ALT-F1 terminal, and had Mandrake Control Center / Internet up on the desktop. I watched as the connection went down then came up again. Then switched to the terminal and saw the readout. Thanks. You are a genius!!! It then happened twice more in quick succession. But now it is up and running!
I discovered the following whilst playing with your script:
Reconnecting to the internet appeared to be a two-stage process with Mandrake 9.0 first to set up eth1 and second to actually do the necessary handshaking down the network.
The other problem is that your "test" to see whether the script needed to kick in only worked if the connection went down unaided. If I typed ifdown eth1 or ifconfig eth1 down, or diconnected using Mandrake Control Center, it did not kick in! When it goes down by itself, the system returns an error which causes the "if condition" line to fail and the code is executed. Not ideal but it works.
A typical outage and reconnection causes the following lines to appear in the console:
eth1: error fetching interface information: Device not found
Resetting eth1 for 2 times
Determining IP information for eth1... done
dhcpcd.exe: interface eth1 has been configured with old IP=xx.xx.xx.xx
Hopefully eth1 up by now!
The other problem was that 'ifup eth1' did not run unless I ran 'ifconfig eth1 up' and 'ifdown eth1' first. Don't ask me why but I tried everything!
By the way if anyone is reading this using KDE but does not know their MAC number you run the KDE Control Centre then select Information / USB Devices then highlight your USB cable modem from the list (mine is Ambit USB Cable Modem. Your MAC address is simply the Serial Number.
There are other ways from the command line of course...
Anyway, we're up and running!
In the spirit of Open Source Free Software I will have to let Linux Format Magazine know. Do you mind if I give them your name?
DAVE