well..since noone helped with the Pattern search part of my request today, I managed to muster up the rather lengthy script on my own. It was successfully tested using optiPerl3 (my favorite)..flawless. One problem though, it's too long. Can some one tighten this code up by a few lines and still produce the same results??
#!/usr/bin/perl -w
open(IN, "< jobreader.txt" or die "Cannot open file for read\n";
open(OUT, "> jobreaderout.txt" or die "Cannot open file for write\n";
my ($sname, $jname, $commd, $logon, $ descr, $recvy);
while(<IN>) {
chomp;
if (m/(.*)#(.*) (SCRIPTNAME||DOCOMMAND) (.*)$/) {
$sname=$1, $jname=$2, $commd=$4;
}elsif (m/(.*) (SCRIPTNAME||DOCOMMAND) (.*)$/) {
$sname="TRAP999A", $jname=$1, $commd=$3;
}elsif (m/(STREAMLOGON) (.*)$/) {
$logon=$2;
}elsif (m/(DESCRIPTION) (.*)$/) {
$descr=$2;
}elsif (m/(RECOVERY) (.*)$/) {
$recvy=$2;
print OUT "$sname\|$jname\|$commd\|$logon\|$descr\|$recvy\n";
$sname = "", $jname="", $commd="";
}
}
Close (IN);
Close (OUT);
SAMPLE IN.TXT FILE IN
MBQR123A#RPM123DP SCRIPTNAME "/usr/bin/tryout.sh"
STREAMLOGON "root"
DESCRIPTION "Experimental Script"
RECOVERY STOP
FRTT544A#RTD123DP DOCOMMAND "/usr/ben/hammerhead.sh"
STREAMLOGON "root"
DESCRIPTION "Some silly script"
RECOVERY STOP
JHGF733A#GGG366DP SCRIPTNAME "/usr/local/sniffer.sh"
STREAMLOGON "fred"
DESCRIPTION "Checks for Ports"
RECOVERY STOP
REDF511 SCRIPTNAME "/usr/local/thetrap.sh"
STREAMLOGON "tuff"
DESCRIPTION "Tricky script B1"
RECOVERY STOP
SAMPLE OUT.TXT FILE
MBQR123A|RPM123DP|"/usr/bin/tryout.sh" |"root" |"Experimental Script" |STOP
FRTT544A|RTD123DP|"/usr/ben/hammerhead.sh" |"root" |"Some silly script" |STOP
JHGF733A|GGG366DP|"/usr/local/sniffer.sh" |"fred" |"Checks for Ports" |STOP
TRAP999A|REDF511|"/usr/local/thetrap.sh" |"tuff" |"Tricky script B1" |STOP
#!/usr/bin/perl -w
open(IN, "< jobreader.txt" or die "Cannot open file for read\n";
open(OUT, "> jobreaderout.txt" or die "Cannot open file for write\n";
my ($sname, $jname, $commd, $logon, $ descr, $recvy);
while(<IN>) {
chomp;
if (m/(.*)#(.*) (SCRIPTNAME||DOCOMMAND) (.*)$/) {
$sname=$1, $jname=$2, $commd=$4;
}elsif (m/(.*) (SCRIPTNAME||DOCOMMAND) (.*)$/) {
$sname="TRAP999A", $jname=$1, $commd=$3;
}elsif (m/(STREAMLOGON) (.*)$/) {
$logon=$2;
}elsif (m/(DESCRIPTION) (.*)$/) {
$descr=$2;
}elsif (m/(RECOVERY) (.*)$/) {
$recvy=$2;
print OUT "$sname\|$jname\|$commd\|$logon\|$descr\|$recvy\n";
$sname = "", $jname="", $commd="";
}
}
Close (IN);
Close (OUT);
SAMPLE IN.TXT FILE IN
MBQR123A#RPM123DP SCRIPTNAME "/usr/bin/tryout.sh"
STREAMLOGON "root"
DESCRIPTION "Experimental Script"
RECOVERY STOP
FRTT544A#RTD123DP DOCOMMAND "/usr/ben/hammerhead.sh"
STREAMLOGON "root"
DESCRIPTION "Some silly script"
RECOVERY STOP
JHGF733A#GGG366DP SCRIPTNAME "/usr/local/sniffer.sh"
STREAMLOGON "fred"
DESCRIPTION "Checks for Ports"
RECOVERY STOP
REDF511 SCRIPTNAME "/usr/local/thetrap.sh"
STREAMLOGON "tuff"
DESCRIPTION "Tricky script B1"
RECOVERY STOP
SAMPLE OUT.TXT FILE
MBQR123A|RPM123DP|"/usr/bin/tryout.sh" |"root" |"Experimental Script" |STOP
FRTT544A|RTD123DP|"/usr/ben/hammerhead.sh" |"root" |"Some silly script" |STOP
JHGF733A|GGG366DP|"/usr/local/sniffer.sh" |"fred" |"Checks for Ports" |STOP
TRAP999A|REDF511|"/usr/local/thetrap.sh" |"tuff" |"Tricky script B1" |STOP