RE: Programming pipes to and from another program
Peter, The openX() funcs are *nix based, and NT is very different in these areas, so my code probably won't help much, and may take you down the long and winding road 8-((. All our automation is nix based for reliability and manageability - you might consider a Linux box 8-)? but that is an even longer road..., then again, commercial support for PGP is no longer available, and OpenGPG is being much more actively maintained... 8-) FWIW we use these NT cmd commands to PGP on NT: export PGPPASSFD=0 pgp -es data.txt receiver@somewhere -o data.txt.pgp -u me@here < password.txt you might consider making passwd.txt a transient file created on the fly by your script and erased afterwards. Your script would need some way of knowing what the passphrase is. regards Jeff > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: 25 September 2002 16:20 > To: Jeff AA > Cc: [EMAIL PROTECTED] > Subject: RE: Programming pipes to and from another program > > > > > >If *nix, look at help for the open3 function. Attached as a > text file is > > > >the little run class that I use to do this. > > > >Here is an example of how to use this class to encapsulate GPG, where > >the passphrase gets written to stdin of the child process, and the > >results are reaped from the childs stderr and the decrypted contents > >from the childs stdin. > >[snip] > > Jeff, > > This is exactly the kind of process I'm having trouble with! PGP > encription. Unfortunatly, I'm forced to work on W2K. I > haven't had much > luck with IPC::Open2, but I'll see if I can adapt this fine code. > > Thanks for the responce, > Peter > > > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Programming pipes to and from another program
>If *nix, look at help for the open3 function. Attached as a text file is > >the little run class that I use to do this. > >Here is an example of how to use this class to encapsulate GPG, where >the passphrase gets written to stdin of the child process, and the >results are reaped from the childs stderr and the decrypted contents >from the childs stdin. >[snip] Jeff, This is exactly the kind of process I'm having trouble with! PGP encription. Unfortunatly, I'm forced to work on W2K. I haven't had much luck with IPC::Open2, but I'll see if I can adapt this fine code. Thanks for the responce, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Programming pipes to and from another program
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 25, 2002 8:52 AM > To: [EMAIL PROTECTED] > Subject: Programming pipes to and from another program > > ... > Is there a simple (or even complex) way to open a two way > pipe to another > program with Perl. Start with perldoc -q 'pipe both' Which leads you to perldoc perlipc (search for "Bidirectional Communication with Another Process") > (I don't want to use Expect or any other scripting > language if I can help it). Depending on the program you're trying to control, you may not have a choice. Some programs require that stdin/out be a tty. Perl's Expect module is easy to use. > I'm trying to implement batch code for automating processes > over night. > Some of these require a dialog. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Programming pipes to and from another program
If *nix, look at help for the open3 function. Attached as a text file is the little run class that I use to do this. Here is an example of how to use this class to encapsulate GPG, where the passphrase gets written to stdin of the child process, and the results are reaped from the childs stderr and the decrypted contents from the childs stdin. my $in = $ARGV[0]; # filename my @cmds = ( '/usr/bin/gpg', '--decrypt', '--batch', '--passphrase-fd', '0', $in, ); # === # SECURITY SENSITIVE. # === # This array gets written to STDIN of the spawned process # Dont forget to include newlines! my @secrets = ( "gpgpasswordgoeshere\n", ); # === my $run = new psRun; $run->run( die => 0, warn=> 0, command => \@cmds, stdin => \@secrets ); my @results = (@{$run->{stderr}}); my @decrypted = (@{$run->{stdout}}); Regards Jeff > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: 25 September 2002 13:52 > To: [EMAIL PROTECTED] > Subject: Programming pipes to and from another program > > > Hi there, > > I hope this is a trivial newbie problem: > > I know how to open a pipe to another program: > open (OUT, "|perl .\\bogus.pl") or warn "Unable to open pipe to > bogus.pl\n"; > print OUT "Stuff\n"; > > And I know how to open a pipe from another program: > open (IN, "perl .\\bogus.pl|") or warn "Unable to open pipe from > bogus.pl\n"; > $input = ; > > But when I try to do both... > open (OUT, "|perl .\\bogus.pl") or warn "Unable to open pipe to > bogus.pl\n"; > open (IN, "perl .\\bogus.pl|") or warn "Unable to open pipe from > bogus.pl\n"; > or > open (BOGUS, "|perl .\\bogus.pl|") or warn "Unable to > open pipe for > bogus.pl\n"; > > strange things happen. > > Is there a simple (or even complex) way to open a two way > pipe to another > program with Perl. (I don't want to use Expect or any other scripting > language if I can help it). > I'm trying to implement batch code for automating processes > over night. > Some of these require a dialog. > > TIA > Peter > > > ** CONFIDENTIALITY NOTICE ** > THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN > CONFIDENTIAL AND > PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). > ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY > PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO > RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY > REPLY E-MAIL AND REMOVE ALL COPIES OF THIS MESSAGE. THANK YOU. > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > #!/usr/bin/perl -w # == # psRun: Run a system command - run John run! # Use this class to run system commands # It provides access to the command's STDIN(write), STDOUT and STDERR (read) # and records exit code and signal # # No warranty or support # # Example usage: # my $run = psRun->new(); # $run->run( command => @cmd, stdin => @inputs ); # print "'@{$run->{command}}' resulted in: exit=>$run->{exit} signal=>$run->{signal}"; # print "'@{$run->{command}}' printed the following on STDERR:\n",join("\nSTDERR: ",@{$run->{stderr}},"\\n\n"; # print "'@{$run->{command}}' printed the following on STDOUT:\n",join("\nSTDOUT: ",@{$run->{stdout}},"\\n\n"; # # Other notes # new( die => 0,...)don't die of non-zero exit codes/signals by default # new( stdin => @inputs,... ) these inputs are written to all run calls by default # # run( die => 0,...)don't die of non-zero exit codes, this run only # new( stdin => @inputs,... ) these inputs for this run only, [overrides any default] # # == # Source Control # $Revision: 1.8 $ # $Date: 2002/05/21 11:02:12 $ # $RCSfile: psRun.pm,v $ # == package psRun; use strict; use English; use FileHandle; use IPC::Open3; use POSIX; use psUtils;
Programming pipes to and from another program
Hi there, I hope this is a trivial newbie problem: I know how to open a pipe to another program: open (OUT, "|perl .\\bogus.pl") or warn "Unable to open pipe to bogus.pl\n"; print OUT "Stuff\n"; And I know how to open a pipe from another program: open (IN, "perl .\\bogus.pl|") or warn "Unable to open pipe from bogus.pl\n"; $input = ; But when I try to do both... open (OUT, "|perl .\\bogus.pl") or warn "Unable to open pipe to bogus.pl\n"; open (IN, "perl .\\bogus.pl|") or warn "Unable to open pipe from bogus.pl\n"; or open (BOGUS, "|perl .\\bogus.pl|") or warn "Unable to open pipe for bogus.pl\n"; strange things happen. Is there a simple (or even complex) way to open a two way pipe to another program with Perl. (I don't want to use Expect or any other scripting language if I can help it). I'm trying to implement batch code for automating processes over night. Some of these require a dialog. TIA Peter ** CONFIDENTIALITY NOTICE ** THIS E-MAIL, INCLUDING ANY ATTACHED FILES, MAY CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION FOR THE SOLE USE OF THE INTENDED RECIPIENT(S). ANY REVIEW, USE, DISTRIBUTION, OR DISCLOSURE BY OTHERS IS STRICTLY PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT (OR AUTHORIZED TO RECEIVE INFORMATION FOR THE RECIPIENT), PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND REMOVE ALL COPIES OF THIS MESSAGE. THANK YOU. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]