Sounds like what you are trying to do is take the file contents, returned from the
cat bash command, pipe it to
gpg to create an un-encrypted password in a new file. At least, that's what the *nix syntax looks like.
If this is the case, I believe you can do this pretty simply by reading in the file using a standard
open() and pipe it to gpg similarly to how you are doing it through your command line.
So...
#!/usr/bin/perl
use strict;
use warnings;
# First, open the file and read the contents... assuming one line
open my $file, 'encrypted_file_name' or die "ERROR:\t$!\n";
my $enc_pass = shift( @{ [ <$file> ] } );
close $file;
# Next, pipe the contents to gpg
open my $gpg_command, "/usr/bin/gpg --option newfile oldfile | "
my $gpg_out;
while ( <$gpg_command> ) {
$gpg_out .= $_;
}
close $gpg_command;
print "$gpg_out\n";
exit;
Given the syntax of your command line interface to gpg, this should do the exact same thing, though via perl.
NOTE: I didn't test this being that I don't know what you are really trying to do here. This is really more of an idea seed that will start pointing you in the right direction!
Good luck!!
---hA||ta----
print map{$_.' '}grep{/\w+/}@{[reverse(qw{Perl Code})]} or die while ( 'trying' );
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.