IPC::Open3
Hi there, I am having trouble making open3 work with perl, v5.6.1 built for i386-linux. I am running Apache/1.3.27 Ben-SSL/1.48 (Unix) PHP/4.2.3 mod_perl/1.27. My problem is that I can't write to STDIN. Does any one know of any solution to this problem? Has any one encountered the same issue? Any suggestions and help is greatly appreciated. -r
Re: IPC::Open3
Rasoul Hajikhani wrote: Hi there, I am having trouble making open3 work with perl, v5.6.1 built for i386-linux. I am running Apache/1.3.27 Ben-SSL/1.48 (Unix) PHP/4.2.3 mod_perl/1.27. My problem is that I can't write to STDIN. Does any one know of any solution to this problem? Has any one encountered the same issue? Any suggestions and help is greatly appreciated. It's a known problem. The solution: s/IPC::Open3/IPC::Run/ Barries has also written IPC::Run3, which should act as a drop-in replacement for IPC::Open3, if you have to stick with the same API. __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
open3 does not proper work in mod_perl context
Hi, I will upgrade from Embedded Perl version 5.00502 for Apache/1.3.6 (Unix) mod_perl/1.19 to Embedded Perl version v5.6.1 for Apache/1.3.23 (Unix) mod_perl/1.26 But now all mod_perl scripts which uses IPC::Open3::open3() fails because STDIN of the new process is closed. I have done some test and found that print(join \n, fileno(STDIN), fileno(STDOUT), fileno(STDERR), '' ); shows 1 1 2 and not the expected 0 1 2 open3 calls xopen \*STDIN, = . fileno $kid_rdr; but because fileno(STDOUT) is equal to fileno(STDIN) the new fileno of STDIN after the dup will be greater than 2 and so closed by the exec call but also as 1 it would not work. Is this a known problem? regards, Silvio
OPEN3
I resolved some of my other open3 related errors by undef stdin, etc per the docs. How stdin or stdout have tow references is beyond me, though. For the time being it works, though. Nonetheless, I have getting the following two (related, I assume) errors. I cannot find any docs on these. Anyone have ideas? BTW, when running a command from OPEN3 on Win2k, should the absolute path be UNIX style or DOS style? E.g. /dir1/dir2/prog.exe or c:\dir1\dir2\prog.exe Thanks, Ward [error] open3: Can't call method close on an undefined value at C:/Perl/lib/IPC/Open3.pm line 327, _GEN_0 line 154. [error] [client 127.0.0.1] [libapreq] remove error on 'C:\WINNT\TEMP\apreq15'
RE: Open3
I tried the following code submitted by Don, but got the following errors. [Tue Apr 9 16:32:38 2002] nul: untie attempted while 1 inner references still exist at C:/apache/Apache/cgi-lib/FLOE/App/Btops.pm line 101. [Tue Apr 9 16:32:38 2002] nul: untie attempted while 1 inner references still exist at C:/apache/Apache/cgi-lib/FLOE/App/Btops.pm line 102. [Tue Apr 09 16:32:38 2002] [error] open3: Can't call method close on an undefined value at C:/Perl/lib/IPC/Open3.pm line 327. Per UNTIE docs, this occurs when a second reference exits for the tied object. I do not see where, though. Further assistance appreciated! Thanks, Ward P.S. I tried to use IPC::Run, but was unsuccessful. seems flakey on win2k. : -Original Message- : From: Don Hayward [mailto:[EMAIL PROTECTED]] : Sent: Thursday, April 04, 2002 6:28 AM : To: Vuillemot, Ward W : Subject: RE: Open3 : : : Hi Ward -- : : Since Perl5.6 someting like this has been necessary for : Open2 and Open3 : under modperl: : : : : my ($stdin, $stdout, $stderr); : $stdin = tied *STDIN; : $stdout = tied *STDOUT; : $stderr = tied *STDERR; : untie *STDIN; : untie *STDOUT; : untie *STDERR; : use FileHandle; : my $Reader = new FileHandle; : my $Writer = new FileHandle; : my $ERR = new Filehandle; : use IPC::Open3; : my $pid = open3( \*Writer,\*Reader, \*ERR, somescript); : unless ($pid) { print open3 failed\n,$c-end_html; exit; } : Writer-autoflush(); : . : . : . : print Writer $stuff\n; : my $ret = Reader; : . : . : . : tie *STDIN, ref $stdin, $stdin; : tie *STDOUT, ref $stdout, $stdout; : tie *STDERR, ref $stderr, $stderr; : : : On Wed, 3 Apr 2002, Vuillemot, Ward W wrote: : : Since we are on the topic...and before some says it is : WOT, I wanted to ask : a corollary question. : : I wrote a simple script to use Open2 as a means of : interacting with some : FORTRAN programs I have. I wanted to create pre and : post-processing using : PERL and leave the numerical stuff (and tons of legacy : code) to the FORTRAN. : Anyway, the Perl script from a command prompt works -- it sends : pre-processed data as STDIN and catches the processed : data from STDOUT : without a hitch. The moment I try it running Apache : 1.33, Perl 5.6.1, : latest version of Open2, and mod_perl the thing just : ties up all the : computer's resources. : : If I could get it to work then I would be a LONG WAY to : really altering the : way we do things at work. : : I have read what docs there are with Perl for this. . : .but I am wondering if : there are any caveats that I should be aware from using : a web-server to : initiate the commands. Or is there an alternative : method I might explore? : : thanks! : Ward : : : -Original Message- : : From: Rasoul Hajikhani [mailto:[EMAIL PROTECTED]] : : Sent: Wednesday, April 03, 2002 1:54 PM : : To: Elizabeth Mattijsen : : Cc: [EMAIL PROTECTED] : : Subject: Re: Open3 : : : : : : Elizabeth Mattijsen wrote: : : : : At 01:44 PM 4/3/02 -0800, Rasoul Hajikhani wrote: : : Hello folks, : : I am writing a web based interface to gpg and am using : : IPC::Open3 and : : IO::Select to manage STDIN, STDOUT and STDERR handles. : : But, I can not : : get stdin to work properly. Here is my code: : : I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 : : (Unix) PHP/4.0.3pl1 : : mod_perl/1.24_01. : : Can anyone see what am I doing wrong? : : : : Make sure your IPC::Open3 is up-to-date. If it is the : : version that came : : with Perl 5.053, it probably has a bug in it. I : : remember having to patch : : it waaay back (like 5 years ago) to get it to : work properly... : : : : Elizabeth Mattijsen : : : : My IPC::Open3 is OK. My problem is with IO::Select. Does : : anyone know : : whether IO::Select has any bugs? I have read the man : : pages and looked : : through the Perl Cook Book for a code snipet that would : : use IO::Select : : to write to STDIN. The one that is in the book does not : : work for me. So : : any comments/suggestions? : : Thanks in advance : : -r : : : : : Don Hayward [EMAIL PROTECTED] : Mote Marine LaboratoryVoice: 941.388.4441 : Cell
Re: Open3
In local.modperl you write: I have asked this question before, and received answers that have helped me in quest. However, my problem persists. So I would like to direct this question to those who have used gpg, and open3. I am having trouble writing to stdin when an apache thread calls open3. However, the same code written as a test script runs fine. I am using the --passphrase-fd 0 option which would instruct gpg to expect the passphrase from stdin rather than keyboard. As I mentioned above, the problem arises when an apache thread tries to execute my code. I know that under perl 5.6 it is necessary to untie STDIN,... (thanks Don Hayward), but I am using perl 5.005_03 built for irix ( Apache/1.3.12 Ben-SSL/1.39 (Unix) mod_perl/1.22). What is happening that I am missing? I'm vaguely remembering reading an article that said this is very non-trivial, and that there is a module to help with the hard part. Have you had a look at Crypt::GPG? http://search.cpan.org/doc/AGUL/Crypt-GPG-1.28/GPG.pm HTH, Lupe Christoph -- | [EMAIL PROTECTED] |http://free.prohosting.com/~lupe | | I have challenged the entire ISO-9000 quality assurance team to a | | Bat-Leth contest on the holodeck. They will not concern us again. | | http://public.logica.com/~stepneys/joke/klingon.htm|
Re: Open3
On Wed, 03 Apr 2002 13:54:09 -0800, Rasoul Hajikhani wrote: Elizabeth Mattijsen wrote: At 01:44 PM 4/3/02 -0800, Rasoul Hajikhani wrote: Hello folks, I am writing a web based interface to gpg and am using IPC::Open3 Try IPC::Run -- Cheers Ron Savage, [EMAIL PROTECTED] on 06/04/2002 http://savage.net.au/index.html
Open3
Folks, I have asked this question before, and received answers that have helped me in quest. However, my problem persists. So I would like to direct this question to those who have used gpg, and open3. I am having trouble writing to stdin when an apache thread calls open3. However, the same code written as a test script runs fine. I am using the --passphrase-fd 0 option which would instruct gpg to expect the passphrase from stdin rather than keyboard. As I mentioned above, the problem arises when an apache thread tries to execute my code. I know that under perl 5.6 it is necessary to untie STDIN,... (thanks Don Hayward), but I am using perl 5.005_03 built for irix ( Apache/1.3.12 Ben-SSL/1.39 (Unix) mod_perl/1.22). What is happening that I am missing? Thanks in advance -r
Open3
Hello folks, I am writing a web based interface to gpg and am using IPC::Open3 and IO::Select to manage STDIN, STDOUT and STDERR handles. But, I can not get stdin to work properly. Here is my code: $gpgCommand = gpg --homedir $home --no-default-keyring --secret-keyring rasoul.asc --decrypt $encryptedFile; print $gpgCommand\n; $pid= open3(*FIN,*FOUT,*FERR,$gpgCommand); $SIG{CHLD} = sub { print REAPER: status $? on $pid\n if waitpid($pid,0) 0 }; $selector = IO::Select-new(); $selector-add(*FOUT,*FERR); while (handles = $selector-handles) { foreach my $fh (handles) { if (fileno($fh) == fileno(FERR)) { print STDERR: , scalar FERR } elsif (fileno($fh) == fileno(FOUT)) { out= FOUT; } elsif ((fileno($fh) == fileno(FIN)) { print FIN $passPhrase\n; } $selector-remove($fh) if eof($fh); } } $pf-close; close FERR; close FIN; close FOUT; I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 (Unix) PHP/4.0.3pl1 mod_perl/1.24_01. Can anyone see what am I doing wrong? Thanks in advance -r
IPC::Open3 Corrected code version
Hello folks, I am writing a web based interface to gpg and am using IPC::Open3 and IO::Select to manage STDIN, STDOUT and STDERR handles. But, I can not get stdin to work properly. Here is my code: $gpgCommand = gpg --homedir $home --no-default-keyring --secret-keyring rasoul.asc --decrypt $encryptedFile; print $gpgCommand\n; $pid= open3(*FIN,*FOUT,*FERR,$gpgCommand); $SIG{CHLD} = sub { print REAPER: status $? on $pid\n if waitpid($pid,0) 0 }; $selector = IO::Select-new(); $selector-add(*FIN,*FOUT,*FERR); while (handles = $selector-handles) { foreach my $fh (handles) { if (fileno($fh) == fileno(FERR)) { print STDERR: , scalar FERR } elsif (fileno($fh) == fileno(FOUT)) { out= FOUT; } elsif ((fileno($fh) == fileno(FIN)) { print FIN $passPhrase\n; } $selector-remove($fh) if eof($fh); } } $pf-close; close FERR; close FIN; close FOUT; I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 (Unix) PHP/4.0.3pl1 mod_perl/1.24_01. Can anyone see what am I doing wrong? Thanks in advance -r
Re: Open3
At 01:44 PM 4/3/02 -0800, Rasoul Hajikhani wrote: Hello folks, I am writing a web based interface to gpg and am using IPC::Open3 and IO::Select to manage STDIN, STDOUT and STDERR handles. But, I can not get stdin to work properly. Here is my code: I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 (Unix) PHP/4.0.3pl1 mod_perl/1.24_01. Can anyone see what am I doing wrong? Make sure your IPC::Open3 is up-to-date. If it is the version that came with Perl 5.053, it probably has a bug in it. I remember having to patch it waaay back (like 5 years ago) to get it to work properly... Elizabeth Mattijsen
Re: Open3
Elizabeth Mattijsen wrote: At 01:44 PM 4/3/02 -0800, Rasoul Hajikhani wrote: Hello folks, I am writing a web based interface to gpg and am using IPC::Open3 and IO::Select to manage STDIN, STDOUT and STDERR handles. But, I can not get stdin to work properly. Here is my code: I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 (Unix) PHP/4.0.3pl1 mod_perl/1.24_01. Can anyone see what am I doing wrong? Make sure your IPC::Open3 is up-to-date. If it is the version that came with Perl 5.053, it probably has a bug in it. I remember having to patch it waaay back (like 5 years ago) to get it to work properly... Elizabeth Mattijsen My IPC::Open3 is OK. My problem is with IO::Select. Does anyone know whether IO::Select has any bugs? I have read the man pages and looked through the Perl Cook Book for a code snipet that would use IO::Select to write to STDIN. The one that is in the book does not work for me. So any comments/suggestions? Thanks in advance -r
Re: IPC::Open3 Corrected code version
This is a known issue with latest mod_perl. Search the archives for details. This is the temp. solution. Before you call open3() do: untie(*STDIN); untie(*STDOUT); Sreeji --- Rasoul Hajikhani [EMAIL PROTECTED] wrote: Hello folks, I am writing a web based interface to gpg and am using IPC::Open3 and IO::Select to manage STDIN, STDOUT and STDERR handles. But, I can not get stdin to work properly. Here is my code: $gpgCommand = gpg --homedir $home --no-default-keyring --secret-keyring rasoul.asc --decrypt $encryptedFile; print $gpgCommand\n; $pid= open3(*FIN,*FOUT,*FERR,$gpgCommand); $SIG{CHLD} = sub { print REAPER: status $? on $pid\n if waitpid($pid,0) 0 }; $selector = IO::Select-new(); $selector-add(*FIN,*FOUT,*FERR); while (@handles = $selector-handles) { foreach my $fh (@handles) { if (fileno($fh) == fileno(FERR)) { print STDERR: , scalar FERR } elsif (fileno($fh) == fileno(FOUT)) { @out= FOUT; } elsif ((fileno($fh) == fileno(FIN)) { print FIN $passPhrase\n; } $selector-remove($fh) if eof($fh); } } $pf-close; close FERR; close FIN; close FOUT; I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 (Unix) PHP/4.0.3pl1 mod_perl/1.24_01. Can anyone see what am I doing wrong? Thanks in advance -r __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com
RE: Open3
Since we are on the topic...and before some says it is WOT, I wanted to ask a corollary question. I wrote a simple script to use Open2 as a means of interacting with some FORTRAN programs I have. I wanted to create pre and post-processing using PERL and leave the numerical stuff (and tons of legacy code) to the FORTRAN. Anyway, the Perl script from a command prompt works -- it sends pre-processed data as STDIN and catches the processed data from STDOUT without a hitch. The moment I try it running Apache 1.33, Perl 5.6.1, latest version of Open2, and mod_perl the thing just ties up all the computer's resources. If I could get it to work then I would be a LONG WAY to really altering the way we do things at work. I have read what docs there are with Perl for this. . .but I am wondering if there are any caveats that I should be aware from using a web-server to initiate the commands. Or is there an alternative method I might explore? thanks! Ward : -Original Message- : From: Rasoul Hajikhani [mailto:[EMAIL PROTECTED]] : Sent: Wednesday, April 03, 2002 1:54 PM : To: Elizabeth Mattijsen : Cc: [EMAIL PROTECTED] : Subject: Re: Open3 : : : Elizabeth Mattijsen wrote: : : At 01:44 PM 4/3/02 -0800, Rasoul Hajikhani wrote: : Hello folks, : I am writing a web based interface to gpg and am using : IPC::Open3 and : IO::Select to manage STDIN, STDOUT and STDERR handles. : But, I can not : get stdin to work properly. Here is my code: : I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 : (Unix) PHP/4.0.3pl1 : mod_perl/1.24_01. : Can anyone see what am I doing wrong? : : Make sure your IPC::Open3 is up-to-date. If it is the : version that came : with Perl 5.053, it probably has a bug in it. I : remember having to patch : it waaay back (like 5 years ago) to get it to work properly... : : Elizabeth Mattijsen : : My IPC::Open3 is OK. My problem is with IO::Select. Does : anyone know : whether IO::Select has any bugs? I have read the man : pages and looked : through the Perl Cook Book for a code snipet that would : use IO::Select : to write to STDIN. The one that is in the book does not : work for me. So : any comments/suggestions? : Thanks in advance : -r :
open3 and mod_perl
Hello folks, I am writing a web interface for the GPGP module that would allow users to create a new public and private key and adds them to the corporate key ring. I will be useing IPC::Open3 and IO::Select to control stdin and stdout of GPGP. Are there any issues that I should be aware w/ these packages under mod_perl? Any suggestions and comments would be greatly welcomed. Thanks in advance -r
Re: open3 and mod_perl
Rasoul Hajikhani wrote: Hello folks, I am writing a web interface for the GPGP module that would allow users to create a new public and private key and adds them to the corporate key ring. I will be useing IPC::Open3 and IO::Select to control stdin and stdout of GPGP. Are there any issues that I should be aware w/ these packages under mod_perl? Any suggestions and comments would be greatly welcomed. Thanks in advance I don't use IPC::Open3, but this is still in the STATUS file http://marc.theaimsgroup.com/?l=apache-modperlm=98839218229712w=2 marc seems to be down at the moment, so this might be the same report (I can't remember) http://mathforum.org/epigone/modperl/dwoxmixsnen HTH --Geoff
Re: [Slightly OT] IPC::Open3 broken in mod_perl/perl 5.6.0?
On Mon, 17 Apr 2000, Richard Titmuss wrote: Hi, I have also had this problem. I checked the modperl-cvs archive and this problem has been fixed in the development release. yes, the cvs version implements Apache::OPEN I still have an problem using IPC::Open2. This can be demonstrated by: use IPC::Open2; $pid = open2(\*A, \*B, '/usr/bin/ls'); The error log shows: [error] Can't locate object method "FILENO" via package "Apache" at /usr/local/lib/perl5/5.6.0/IPC/Open3.pm line 183. does this fix it: sub Apache::FILENO { untie *STDOUT; fileno STDOUT; } ?
Re: [Slightly OT] IPC::Open3 broken in mod_perl/perl 5.6.0?
Hi, I have also had this problem. I checked the modperl-cvs archive and this problem has been fixed in the development release. I still have an problem using IPC::Open2. This can be demonstrated by: use IPC::Open2; $pid = open2(\*A, \*B, '/usr/bin/ls'); The error log shows: [error] Can't locate object method "FILENO" via package "Apache" at /usr/local/lib/perl5/5.6.0/IPC/Open3.pm line 183. I do not understand enough about the perl/mod-perl guts to produce a patch. Any help appreciated. Thanks, Richard -- Richard Titmuss Email: [EMAIL PROTECTED] B55 Rm122, BT Laboratories Martlesham HeathTel: +44 (0)1473 640306 Ipswich, Suffolk, IP5 3RE, UK Fax: +44 (0)1473 646885
[Slightly OT] IPC::Open3 broken in mod_perl/perl 5.6.0?
Sorry if this is slightly off topic. I seem to have run into problems using IPC::Open3 under mod_perl 1.22 and perl 5.6.0. This probelm only seems to have cropped up after I upgraded form perl 5.005 to perl 5.6.0. What happens is I have an exception handler that opens gpg and uses gpg to encrypt some data and email it to me in the case of an exception. The code looks like this: my $input = new IO::Handle; my $output = new IO::Handle; my $error = new IO::Handle; my $cmd = "gpg --homedir /etc/httpd/perl/gkgnsi/gpg -r $to -ea"; my $pid = IPC::Open3::open3($input, $output, $error, $cmd); THis worked fine when I was running perl 5.005, but now it dies here, and the apache error_log shows: [error] Can't locate object method "OPEN" via package "Apache" at /usr/lib/perl5/5.6.0/IPC/Open3.pm line 132. Strange... Has anyone seen anything like this? Anyone have any ideas? Thanks. Mike