#!/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 = "/root/sysedge/cf_files"; #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 =~ /bgs/){ print $line; if ($line =~ m/$agent/){ $line = $collect; # next; } if ( $line =~ m/best1collect/) { $line = $collect; # next; } } else { ($line =~ m/'syslogd'\)/); my $newline = $. + 3; $newline = $bgs; print OUT $newline; next; } #} } continue { print OUT $line; #print $line; } }