I am trying to migrate a couple scripts off an old red hat box and onto an ubuntu box. 1 of the 2 works fine, the one below does not, it kicks this error message out when I try to run it:
Line 75 of the script is this : abort( "Internal Error:"
Here is the script:
I am very new to Perl and haven't been able to figure this out via google. Any idea what I need to do to fix this?
Code:
+++ Attempting to view license '12345-111111-20080902-0142089.gpg'
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ Checking Customer License Signature
gpg: WARNING: unsafe permissions on homedir `/home/prod/license/gpg.public'
gpg: Signature made Tue 02 Sep 2008 11:08:49 AM EDT using XXXX key ID XXXXXXX
gpg: Good signature from "XXXXXX Customer Control <support@XXXXX.com>"
+++ Unpacking License File
Undefined subroutine &main::abort called at ./showLicense line 75.
Line 75 of the script is this : abort( "Internal Error:"
Here is the script:
Code:
#!/usr/bin/perl
use strict;
if ( !@ARGV ) {
print STDERR "Usage: $0 <license_file> ...\n";
exit -1;
}
my $homeDir = "/home/prod/license/gpg.public";
if ( ! -d $homeDir ) {
$homeDir = "/prod/netmri/src/setup/gpg.public";
if ( ! -d $homeDir ) {
$homeDir = "/root/.gpg";
if ( ! -d $homeDir ) {
print STDERR "Unable to locate gpg.public keyring\n";
exit -1;
}
}
}
my $tmpDir = "/tmp";
foreach my $inputFile (@ARGV) {
print "\n";
print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
print "+++ Attempting to view license '$inputFile'\n";
print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
print "+++ Checking Customer License Signature\n";
my $licenseTar = "license.tgz";
my $cmd = "/bin/echo \"It's really just a bunch of ones and zeros\" | "
. "/usr/bin/gpg "
. " --homedir=$homeDir"
. " --quiet --batch"
. " --no-secmem-warning"
. " --passphrase-fd 0"
. " --output $tmpDir/$licenseTar"
. " --decrypt $inputFile 2>&1";
my $result = `$cmd`;
print "$result\n";
if ( $result =~ /decryption failed: secret key not available/ ) {
print "+++ Checking Evaluation License Signature\n";
$cmd = "/bin/echo \"java.lang.SecurityException: Invalid Passphrase\" | "
. "/usr/bin/gpg "
. " --homedir=$homeDir"
. " --quiet --batch"
. " --no-secmem-warning"
. " --passphrase-fd 0"
. " --output $tmpDir/$licenseTar"
. " --decrypt $inputFile 2>&1";
$result = `$cmd`;
print "$result\n";
if ( $result =~ /decryption failed: secret key not available/ ) {
abort ( "Decryption Failure: $result" );
}
}
if ($result !~ /Good signature/) {
abort ("Invalid Digital Signature:"
. " The given file has not been properly signed"
. " by xxxxxx, Inc. Please ensure that the correct filename was specified."
);
}
print "+++ Unpacking License File\n";
system ( "cd $tmpDir; /bin/tar xfm $licenseTar"
. " --use-compress-program /usr/bin/gzip"
. " >/dev/null 2>&1" );
if ($?) {
abort( "Internal Error:"
. " The given license file could not be unpacked properly."
. " Please contact support\@xxxxxx.com."
);
}
# Get the directory that was just unpacked by looking at the
# tar file in case the user changed the name of the license
# file.
my $newLicenseDir = `cd $tmpDir; (/bin/tar tfz $licenseTar | /usr/bin/head -1)`;
chomp $newLicenseDir;
$newLicenseDir =~ s|/||g;
my $metaFile = "$tmpDir/$newLicenseDir/metaData.cfg";
if ( ! -f $metaFile ) {
abort ( "Invalid License Package:"
. " Meta data file missing from license package ($tmpDir/$newLicenseDir)." );
}
open ( META, $metaFile ) || abort ( "Error Processing License:"
. " Can't open meta data file ($!) from license package." );
print "\n";
print "+++ License contents starts.\n\n";
while (<META>) {
print "$_";
}
print "\n+++ License contents ends.\n";
close (META);
# Clean up tmpDir
system ("rm -fr $tmpDir/$newLicenseDir");
system ("rm -f $tmpDir/$licenseTar");
I am very new to Perl and haven't been able to figure this out via google. Any idea what I need to do to fix this?