I used double's around sed, just like you had.. I think I found the prob though, I was #!/bin/sh 'ing not #!/bin/bash 'ing.. it now likes the new script you wrote out. I'm now using apachectl graceful to restart the server as well with no need for the kill command.. I found cut -c 0-5 was ok for killing the processes, because the max chars it had was 5 and it seemed to ignore the white spaces that occured.. The only problem was that it then tried to kill every other httpd that it had found in the grep and so it was trying to kill processes that weren't there. I had since changed that to "killall httpd" and that worked alright. but apachectl looks to be cleaner as you said (no one would be using my webserver if I'm changing ip's because it would mean my modem's dropped out :) ) Muchos Gracias Angus, Paul > ?? you didn't use single quotes instead, did you? > > (and its the shell, not sed that does the variable substitution - the > shell should expand the line before giving it to sed) > > > #Insert new IP in all required places. > > /usr/bin/sed "s/@MYIP@/`/sbin/ifconfig ppp0|grep inet|cut -c 21-33`/g" \ > > < /www/conf/httpd.conf.orig > /www/conf/httpd.conf > > #Restart httpd > > kill `ps -ax |grep /usr/sbin/httpd | cut -c 0-5` > > /usr/sbin/httpd > > the "cut -c"s make me nervous .. a new version of some tool will come > out that adds a little whitespace and suddenly your script is off > killing the wrong processes > > try: > > myip=`/sbin/ifconfig ppp0 | sed -n 's/^.* addr:\([0-9.]\+\) .*$/\1/p'` > sed "s/@MYIP@/$myip/" < httpd.conf.orig > httpd.conf > kill `ps -ax | grep '[/]usr/sbin/httpd' | cut -d' ' -f 1` > /usr/sbin/httpd > > > (the square brackets on the grep regex is an amusing trick i once saw > to avoid matching the grep process itself - better would be to use > pidof(8) or similar) > > > nb I use this method below for restarting httpd because there is no rc > > files for apache in the distro of slakware that I have and because kill > > -HUP isn't too reliable as I've found with my testing of the script above > > (like it doesn't always restart it). > > apache has a nice "graceful" reload (triggered by SIGUSR1) - where it > won't interrupt any current requests. you might want to consider using > that if you have other users who might be using apache while you > change IPs.. > > my apache (debian) comes with a script "apachectl", which sends > signals, etc to the right apache process. if you have such a script i > suggest using it (its much cleaner). > > -- > - Gus > -- > SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au > To unsubscribe send email to [EMAIL PROTECTED] with > unsubscribe in the text > -- ----------------------------------------------- Paul Robinson Senior Web Developer Centre for Flexible Learning Macquarie University NSW 2109, Australia Voice: +61 2 9850 8424 Email: [EMAIL PROTECTED] ----------------------------------------------- -- SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au To unsubscribe send email to [EMAIL PROTECTED] with unsubscribe in the text
