#!/usr/bin/perl -w use strict; my $agent = "best1agent_start"; my $bgs=<>\$LOG 2>>\$LOG ;; HERE my $collect = " /usr/bin/su - patrol /usr/adm/best1_default/bgs/scripts/best1collect -q>>\$LOG 2>>\$LOG\n"; my $cf_dir = "/export/home/f358118/sysedge"; open SH_FILES, "sys.sh" or die "Error: $!"; my @sh_f=; close SH_FILES; foreach my $sh(@sh_f){ chomp $sh; open(OUT, ">/$cf_dir/$sh".".OUT")or die "ERROR $!"; my $line; open (SH, "$cf_dir/$sh") or die "ERROR $!"; while ($line = ){ if($line =~ m/$agent/){ $line = $collect; } elsif ( $line =~ m/best1collect/) { next; } elsif ($line =~ m/'syslogd'\)/){ my $newline = $. + 3; $newline = $bgs; print OUT "$newline\n"; } #else { next }; print OUT $line; print $line; } }