Created
June 19, 2023 13:56
-
-
Save earnhardt3rd/babc528958b8dd65288f67b463be3f33 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'getopts.pl'; | |
| Getopts('m:d:t'); | |
| my $MODE = uc($opt_m) || ""; | |
| my $DEBUG = $opt_d || 0; | |
| if (defined $opt_t) { my %TEST = &findStrInFile();} | |
| 1; | |
| sub findStrInFile { | |
| my $sFile = shift || ""; | |
| my $sCom = shift || ""; | |
| my $sStr = shift || ""; | |
| my $gawk = shift || ""; | |
| my $rtn = ""; | |
| print "--findStrInFile\n {\n" if $DEBUG >0; | |
| if ($sStr eq "") { | |
| print " Nothing to Search for???\n"; | |
| return "ERROR! Nothing to Search For???"; | |
| } | |
| if (! -f $sFile) { | |
| print " Could not locate search file: $sFile\n"; | |
| return "ERROR! Could not locate file:$sFile"; | |
| } | |
| print " Looking for:'$sStr' in '$sFile'\n" if $DEBUG >0; | |
| my $cmd = "findstr /C:\"${sStr}\" \"${sFile}\""; | |
| if ($sCom ne "") {$cmd .= "|findstr /V /C:^${sCom}";} | |
| if ($gawk ne "") {$cmd .= "|gawk \"{${gawk}}\"";} | |
| print " --$cmd\n" if $DEBUG >0; | |
| my $cmdX = `$cmd 2>&1`; | |
| chomp($cmdX); | |
| print " --$cmdX\n" if $DEBUG >0; | |
| if ($cmdX eq "") { | |
| $rtn="NOT_FOUND"; | |
| } else { | |
| $rtn = $cmdX; | |
| $rtn =~ s/.*${sStr}//; | |
| $rtn =~ s/"//g; | |
| if ($rtn =~ /^PDM/) {$rtn =~ s/^PDM/${PDM}/;} | |
| if ($rtn =~ /^NXROOT/) {$rtn =~ s/^NXROOT/${NXROOT}/;} | |
| } | |
| print " RTN:$rtn\n" if $DEBUG >0; | |
| print " }\n" if $DEBUG >0; | |
| return $rtn; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment