IPC Open

2003-07-18 Thread Cameron B. Prince
Hi,

I have the following subroutine in a package that's called by an embperl
page via mod_perl:

sub MP3Check {
   my ($self,$params) = @_;
   use IPC::Open3;
   my ($pid,%values);

   $SIG{ALRM} = sub {
  my $kill = kill -9 $pid;
  system($kill);
  $values{'CHECK_PROBLEM'} = 1;
  return;
   };

   my $command = qq!$self-{MP3Check} -v $params-{file}!;
   alarm(5);
   $pid = open3(*IN, *OUT, *ERR, $command);
   waitpid $pid, 0;
   alarm(0);
   close(IN);
   my @outlines = OUT;
   for ( @outlines ) {
  $values{$1} = $2 if /^([A-Z_]+)\s+(.*)$/;
   }
   return \%values;
}

I'm getting the error message:

[16307]ERR: 24: Error in Perl code: Can't locate object method OPEN via
package Apache::RequestRec at /usr/lib/perl5/5.8.0/IPC/Open3.pm line 136.

I read a post that mentions:

OPEN was added after 1.99_08. Please build the cvs version of mod_perl 2.0:
http://perl.apache.org/download/source.html#2_0_Development_Source_Distribut
ion

I then found this info on building an RPM from CVS:

http://www.gossamer-threads.com/archive/mod_perl_C1/modperl_F7/mod_perl-1.99
_09_for_Redhat_9_P68324/

I got the spec file and built a new rpm:

mod_perl-2.0_cvs-1.99.10

However, I still get the same error...

Can any one give me any ideas on how to fix this?

I also read a post about IPC::Open... I looked at the synopsis and it looks
rather complicated. Is this definately a better way to go?

Any help would be greatly appreciated.

Cameron






Re: IPC Open / IPC Run

2003-07-18 Thread Barrie Slaymaker
On Fri, Jul 18, 2003 at 12:30:22PM -0500, Cameron B. Prince wrote:
 I just realized, I meant to say IPC::Run below from my previous post.
 
  I also read a post about IPC::Open... I looked at the synopsis and it
 looks rather complicated.

Only if you're trying to do something complicated, like keep a long
lived subprocess around and interact with it.  For batch mode
subprocesses, all you need is run().

You might also try IPC::Run3 which is less bloated, but uses temp files
instead of select() to Keep It Simple, Slaymaker.

  Is this definately a better way to go?

Define better ;).  Simpler, yes, if what you're trying to do is
simpler.

- Barrie


Re: IPC Open

2003-07-18 Thread Stas Bekman

I'm getting the error message:

[16307]ERR: 24: Error in Perl code: Can't locate object method OPEN via
package Apache::RequestRec at /usr/lib/perl5/5.8.0/IPC/Open3.pm line 136.
perl -MApache2 -MModPerl::MethodLookup -e print_method  OPEN
to use method 'OPEN' add:
use Apache::RequestIO ();


__
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


Re: [mp2] Apache::RequestRec, IPC::Open[23] problem

2003-01-22 Thread Ville Skyttä
On Wed, 2003-01-22 at 08:10, Stas Bekman wrote:

 Please try again with the latest cvs, I've just ported FILENO, OPEN and CLOSE 
 interfaces from 1.0. Though I doubt that this will work, IPC::Open* have 
 always had problems with mod_perl. IPC::Run should be used instead for now. 
 Hopefully will be able to look more into this issue much later unless someone 
 beats me to it.

Thanks for the quick reply, Stas.  I tried it out and that particular
error is gone now, but the W3C Validator still doesn't quite work,
whereas as a normal CGI it does.  I didn't notice any errors, but valid
pages just don't validate under mod_perl (they do as normal CGI).  I
know this is a too vague explanation, but I don't have time to dig
deeper now.

Cheers,
-- 
\/ille Skyttä
ville.skytta at iki.fi





Re: [mp2] Apache::RequestRec, IPC::Open[23] problem

2003-01-22 Thread Stas Bekman
Ville Skyttä wrote:

On Wed, 2003-01-22 at 08:10, Stas Bekman wrote:



Please try again with the latest cvs, I've just ported FILENO, OPEN and CLOSE 
interfaces from 1.0. Though I doubt that this will work, IPC::Open* have 
always had problems with mod_perl. IPC::Run should be used instead for now. 
Hopefully will be able to look more into this issue much later unless someone 
beats me to it.


Thanks for the quick reply, Stas.  I tried it out and that particular
error is gone now, but the W3C Validator still doesn't quite work,
whereas as a normal CGI it does.  I didn't notice any errors, but valid
pages just don't validate under mod_perl (they do as normal CGI).  I
know this is a too vague explanation, but I don't have time to dig
deeper now.


As I said, the IPC::Open* family is usually not working under mod_perl (1.0 
and 2.0). Nobody has looked into resolving this issue, mainly because IPC::Run 
seems to be a much better alternative. But that doesn't solve the problem for 
those who are stuck with an existing code and aren't able to adjust it. 
Therefore since IPC::Run provides the same functionality and more, may be a 
special IPC::Open* layer can be provided which will transparently replace 
IPC::Open* with IPC::Run.

__
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



[mp2] Apache::RequestRec, IPC::Open[23] problem

2003-01-21 Thread Ville Skyttä
Hi,

The script below under mod_perl 1.99_08 (ModPerl::Registry), gives me
this:

  Can't locate object method FILENO via package
  Apache::RequestRec at /usr/lib/perl5/5.8.0/IPC/Open3.pm line 196.

A real world example of a script that has these problems is the W3C
Markup Validator,
http://dev.w3.org/cvsweb/validator/httpd/cgi-bin/check?rev=1.200.2.79.

The validator works under mod_perl 1, and I guess the test script would
as well (I'm unable to verify that at the moment, though).  Maybe a
mod_perl 2 bug/missing feature?

My installation is Red Hat 8.0, Apache 2.0.40, mod_perl 1.99_08 and Perl
5.8.0.  The test script:

  use IPC::Open2 qw(open2);
  use IO::File ();
  my $in  = IO::File-new_tmpfile();
  my $out = IO::File-new_tmpfile();
  print $in foobar\n;
  seek $in, 0, 0;
  print Content-Type: text/plain\n\n;
  my $pid = open2($out, $in, 'tee');
  undef $in;
  waitpid $pid, 0;
  seek $out, 0, 0;
  while ($out) {
print;
  }
  undef $out;

Cheers,
-- 
\/ille Skyttä
ville.skytta at iki.fi





Re: [mp2] Apache::RequestRec, IPC::Open[23] problem

2003-01-21 Thread Stas Bekman
Ville Skyttä wrote:

Hi,

The script below under mod_perl 1.99_08 (ModPerl::Registry), gives me
this:

  Can't locate object method FILENO via package
  Apache::RequestRec at /usr/lib/perl5/5.8.0/IPC/Open3.pm line 196.

A real world example of a script that has these problems is the W3C
Markup Validator,
http://dev.w3.org/cvsweb/validator/httpd/cgi-bin/check?rev=1.200.2.79.

The validator works under mod_perl 1, and I guess the test script would
as well (I'm unable to verify that at the moment, though).  Maybe a
mod_perl 2 bug/missing feature?

My installation is Red Hat 8.0, Apache 2.0.40, mod_perl 1.99_08 and Perl
5.8.0.  The test script:

  use IPC::Open2 qw(open2);
  use IO::File ();
  my $in  = IO::File-new_tmpfile();
  my $out = IO::File-new_tmpfile();
  print $in foobar\n;
  seek $in, 0, 0;
  print Content-Type: text/plain\n\n;
  my $pid = open2($out, $in, 'tee');
  undef $in;
  waitpid $pid, 0;
  seek $out, 0, 0;
  while ($out) {
print;
  }
  undef $out;


Please try again with the latest cvs, I've just ported FILENO, OPEN and CLOSE 
interfaces from 1.0. Though I doubt that this will work, IPC::Open* have 
always had problems with mod_perl. IPC::Run should be used instead for now. 
Hopefully will be able to look more into this issue much later unless someone 
beats me to it.

__
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