Hey Guys,
I just inherited this Perl script from a former coworker. It works fine if I run it from my account using: sudo perl decrypt.pl foo.pgp bar.txt
If I do a sudo su - root and type: perl decrypt.pl foo.pgp bar.txt
It fails with this error: Use of uninitialized value $plaintext[0] in print at decrypt.pl line 23, <$ciphertext_fh> line 2486.
Thoughts??#!/usr/bin/perl use strict; use warnings; use Crypt::GPG; use Data::Dumper; my $gpg = new Crypt::GPG; $gpg->gpgbin('/usr/bin/gpg'); $gpg->secretkey('xxxxxxxxxx'); $gpg->passphrase('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); my $inputfile = shift; my $outputfile = shift; open my $ciphertext_fh, '<', $inputfile or die "couldn't open $inputfi +le: $!"; open my $output_fh, '>', $outputfile or die "couldn't open $outputfile + for writing: $!"; my @ciphertext = <$ciphertext_fh>; my (@plaintext) = $gpg->decrypt(\@ciphertext) or die "didn't work: $!" +; print $output_fh @plaintext; close $ciphertext_fh; close $output_fh;
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |