Hey guy's,
I wrote a perl script to list files in a certain directory and then give the user the option of typing in what file he/she wants to encrypt. Everything works fine but I want to give the user the option of Deleting the original file by hitting Y or just hitting N and exiting. I have attached the code that I have thus far... Any ideas?
#!/usr/bin/perl
print "***********************************************************************\n";
print "\tWelcome to the Robert's Encryption Script!\n";
print "***********************************************************************\n\n";
my $gpg = ".gpg";
my $out_dir = "/my/out/";
my $dir = '/my/dir/';
opendir(DIR, $dir) or die "Can't get a file listing in $dir: !";
my @array = readdir DIR;
close DIR;
foreach $file (@array) {
print "\t--- Found this file...\n";
print "\t\t--> $file\n";
}
print "\t***********************************************************\n";
print "\t Please type in what file you would like to encrypt...\n";
print "\t***********************************************************\n\n";
print "File Name... \n";
$temp = <STDIN> ;
chop $temp;
print "You Typed--> $temp \n";
print "\t \n";
print "\t***********************************************************\n";
print "\t Begin encryption of file $temp\n";
print "\t***********************************************************\n\n";
print "\t---Attempting to encrypt $temp\n\n";
system "gpg -e -r rolacy < $dir$temp > $out_dir$temp$gpg";
print "\t~~~ Encrypted file name is $out_dir$temp.gpg\n";
I wrote a perl script to list files in a certain directory and then give the user the option of typing in what file he/she wants to encrypt. Everything works fine but I want to give the user the option of Deleting the original file by hitting Y or just hitting N and exiting. I have attached the code that I have thus far... Any ideas?
#!/usr/bin/perl
print "***********************************************************************\n";
print "\tWelcome to the Robert's Encryption Script!\n";
print "***********************************************************************\n\n";
my $gpg = ".gpg";
my $out_dir = "/my/out/";
my $dir = '/my/dir/';
opendir(DIR, $dir) or die "Can't get a file listing in $dir: !";
my @array = readdir DIR;
close DIR;
foreach $file (@array) {
print "\t--- Found this file...\n";
print "\t\t--> $file\n";
}
print "\t***********************************************************\n";
print "\t Please type in what file you would like to encrypt...\n";
print "\t***********************************************************\n\n";
print "File Name... \n";
$temp = <STDIN> ;
chop $temp;
print "You Typed--> $temp \n";
print "\t \n";
print "\t***********************************************************\n";
print "\t Begin encryption of file $temp\n";
print "\t***********************************************************\n\n";
print "\t---Attempting to encrypt $temp\n\n";
system "gpg -e -r rolacy < $dir$temp > $out_dir$temp$gpg";
print "\t~~~ Encrypted file name is $out_dir$temp.gpg\n";