1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 my $file;
7 if ( ! defined $ARGV[0] ) {
8 print "Enter file path to decrypt: ";
9 my $input = <STDIN>;
10 chomp $input;
11 $file = $input;
12 } else {
13 # Expects full path of file
14 $file = $ARGV[0];
15 }
16
17 if ( ! -f $file ) { die "File argument must be a plain file, $file is not a plain file or it cannot be found, exiting...\n" };
18 # Get rid of .gpg
19 my $newFileName = $file;
20 for ( 0 .. 3 ) {
21 my $char = chop($newFileName);
22 }
23
24 print "new filename is $newFileName\n";
25 system("gpg -o $newFileName -d $file") == 0 or die "Something went wrong with GPG, I didn't decrypt the file...";
26
27 print "Looking for decrypted file..\n";
28 if ( -f $newFileName ) {
29 print "Unencrypted file is at: $newFileName\n";
30 } else {
31 print "Something went wrong? I couldn't find the decrypted file, maybe check the dir?\n";
32 exit 1;
33 }