Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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' );

In reply to Re: using a pipe by wazzuteke
in thread using a pipe by drock

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found