wcj75019 has asked for the wisdom of the Perl Monks concerning the following question:
Thank YouYour holinesses. I have a system file with a case statement like this. I need to check and see if the entry 'bgs' is correct? This one is no +t. Most of them are not. I have several hundred files I need to change. Many don't have it. So, for this file I need to change: /sbin/sh /usr/adm/best1_default/bgs/scripts/best1agent_start>>$LOG 2>> +$LOG to: '/usr/bin/su - patrol /usr/adm/best1_default/bgs/scripts/best1agent -q +' Which is strait forward. I leave the ones that are ok alone. Change the ones that are wrong. Add the 3 lines if they are not there after a trigger of something lik +e 'cron'. 'bgs') '/usr/bin/su - patrol /usr/adm/best1_default/bgs/scripts/best1agent + -q' ;; I thought it would be easy. But, I'm having a hell of a time with it. + I've tryed several diferent ways. Logic: I'm not sure about? foreach through the files. open() and while() through each file. check for $line to see if it needs to be changed. If it does, Change it. If not leave it alone. BUT, what if it doesn't have the $line at all? I was thinking early on + in the script to use grep. But, I can't get that to work. Any suggestions would be much appreciated. FILE TO CHANGE: case "$process" in 'cron') /sbin/sh /etc/rc2.d/S75cron start >>$LOG 2>>$LOG ;; 'secmgrd') echo "Starting SECMGRD" >>$LOG /sbin/sh /etc/init.d/iv stop >>$LOG 2>>$LOG /sbin/sh /etc/init.d/iv start >>$LOG 2>>$LOG return ;; 'bgs') /sbin/sh /usr/adm/best1_default/bgs/scripts/best1agent_start>>$LOG +2>>$LOG ;; 'twagent') /sbin/sh /etc/rc2.d/S95twagent start>>$LOG 2>>$LOG ;; 'bvcontrold') /sbin/sh /etc/init.d/bvunix start>>$LOG 2>>$LOG ;; 'dsmcad') /sbin/sh /etc/init.d/adsm_sched>>$LOG 2>>$LOG ;; *) return ;; esac
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I need some pearls of wisdom
by hipowls (Curate) on Feb 23, 2008 at 00:39 UTC | |
|
Re: I need some pearls of wisdom
by pc88mxer (Vicar) on Feb 23, 2008 at 17:06 UTC | |
by wcj75019 (Acolyte) on Feb 24, 2008 at 01:49 UTC |