#!/usr/bin/perl -w use strict; my $CF = "watch process procAlive 'bgs' 18 0x2 60 'Production Critical: bgs failure. Restarting bgs' '/opt/EMPsysedge/bin/sysedge.sh'"; my $file = do { local $/; }; s/^watch.*?'bgs'.*?sh'$//; s/^(watch.*?'cron'.*?sh'$)/$1\n$CF\n/; print $file; __DATA__ watch process procAlive 'cron' 1 0x2 60 'Production Critical: cron failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'inetd' 2 0x2 60 'Production Critical: inetd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'sendmail' 3 0x2 60 'Production Critical: sendmail failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'syslogd' 4 0x2 60 'Production Critical: syslogd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'automountd' 5 0x2 60 'Production Critical: automountd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'xntpd' 6 0x2 60 'Production Critical: xntpd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'itaagtd' 7 0x2 60 'Production Critical: itaagtd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' #### #!/usr/bin/perl -w use strict; my $CF = "watch process procAlive 'bgs' 18 0x2 60 'Production Critical: bgs failure. Restarting bgs' '/opt/EMPsysedge/bin/sysedge.sh'"; while () { next if /bgs/; # skip printing the line with 'bgs' print; # print the line just read in print "$CF\n" if /cron/; # add '$CF' if we just printed the line with 'cron' } __DATA__ watch process procAlive 'cron' 1 0x2 60 'Production Critical: cron failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'inetd' 2 0x2 60 'Production Critical: inetd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'sendmail' 3 0x2 60 'Production Critical: sendmail failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'syslogd' 4 0x2 60 'Production Critical: syslogd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'automountd' 5 0x2 60 'Production Critical: automountd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'xntpd' 6 0x2 60 'Production Critical: xntpd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh' watch process procAlive 'itaagtd' 7 0x2 60 'Production Critical: itaagtd failure. Call USA POC' '/opt/EMPsysedge/bin/sysedge.sh'