| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 49281 | 2004-09-14 23:13:00 | MDK Lin N/Hhood | Dianne2 (6160) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 272433 | 2004-09-15 23:05:00 | I thought that'd happen. That's okay, Graham's been using Redhat a little too long ;-) Try: su - [enter root pw] /etc/init.d/network stop /etc/init.d/network start This should stop your network, and restart it - thereby forcing it to re-assign a Dynamic IP address. |
Chilling_Silence (9) | ||
| 272434 | 2004-09-16 01:58:00 | Right . :D Here's the high technology way to do this . Make a file in /root/bin called IP_Check (if you haven't got a /bin, make it -- mkdir /root/bin) . This file (saved as TEXT, not a WP file) contains: #!/bin/sh # have a look at the IP address we have and take some action # delay=5 if [ `ifconfig eth0` | grep 127 |wc -l != 0 ] ; then echo -n " IP_Check: IP is local --- DHCP not working?"; service network restart; #NOTE 1 echo -n " IP_Check: Have restarted network, will check again in $delay minutes"; at now + $delay min -f /root/bin/IP_Check 2>/dev/nul; else echo -n " IP_Check: IP address looks OK"; fi Then find /etc -name rc . local will find that file for you . Edit that and put in the line /root/bin/IP_Check This was just a few minutes playing last night . . . it works for me . :D At the line marked NOTE 1 use ipdown etho ipup eth0 or ifconfig eth0 down ifconfig eth0 up or whatever works . Samba might get clouted in this . . . as you have noticed . . . so you might have to include service samba start or /etc/rc . d/init . d/smb start /etc/rc . d/init . d/nmb start as well . Nice and simple, isn't it . :D |
Graham L (2) | ||
| 272435 | 2004-09-16 02:50:00 | Graham, Thank you, I think it will take me a while to under stand that. I have coppied it, and shall studie it later. Dianne |
Dianne2 (6160) | ||
| 272436 | 2004-09-17 03:09:00 | There's an oops in that . . . "left as an exercise for the reader" . I wish :D The second "`" character in the test line is in the wrong place . That line should be: if [ `ifconfig eth0 | grep 127 | wc -l` != 0 ] ; then The bolding also makes the pipe character "|" look very much like a lowercase "L" "l" . :-( The argument to the wc is "-l" the lowercase "L" . What that line does is: ifconfig asks for the configuration of the eth0 interface, and passes it (through the pipe--"|") to grep which finds and passes any lines containing "127" to wc (the wordcount programme) with the -l (lines) option . The "`" characters surrounding that return the value of the expression -- which will be 0 or 1 . That value is used in the comparison The whole catastrophe contained in the "["and "]" brackets is a logical comparison (is the value NOTEQUAL ("!=") to 0 and returns TRUE or FALSE . The punctuation (including spaces) must be exactly right . Try building the line up as a series of direct commands . ifconfig eth0 then up-arrow,and add the pipe and grep, ifconfig eth0 |grep 127 then up-arrow, and add another pipe and wc, ifconfig eth0 | grep 127 | wc -l then up-arrow, and change the 127 to a number you'll get and enter that The reverse ticks "`" are used to explicitly pass the result to, e . g . , the if operator in script . Doing it this way will make it "automatic " . . . and users won't have to know the root password . |
Graham L (2) | ||
| 1 2 | |||||