#!/usr/bin/perl -w use strict; my $agent = "best1agent_start"; my $collect = '/usr/bin/su - patrol /usr/adm/best1_default/bgs/scripts/best1collect -q>>$LOG 2>>$LOG'; my $cf_dir = "/root/sysedge/cf_files"; open SH_FILES, "sh.file" or die "Error: $!"; my @sh_f=; close SH_FILES; foreach my $sh(@sh_f){ chomp $sh; open(OUT, "/tmp/$sh".".sysedge.sh"); my $line; open (SH, "$cf_dir/$sh") or die "ERROR $!"; while ($line = ){ if($line =~ /$agent/){ $line = $collect; print OUT $line; } print OUT $line; } }