You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by kh...@wipro.com on 2007/06/20 19:55:15 UTC

Apache Subprocess

Hi Folks,
 
I was trying in the lines of below code from http://perl.apache.org/docs/2.0/api/Apache/SubProcess.html.
 
  # write to/read from the process
  $command = "/tmp/in_out_err.pl";
  ($in_fh, $out_fh, $err_fh) = $r->spawn_proc_prog($command);
  print $in_fh "hello\n";
  $output = read_data($out_fh);
  $error  = read_data($err_fh);
 
The sub process(C program in my case) is never invoked and both input and output streams are empty. Can you please tell me what might be going wrong. I am using mod perl 2
 
Thanks,



The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
 
www.wipro.com

RE: Apache Subprocess

Posted by kh...@wipro.com.
 
Hi Scott,

The program itself is not invoked, I tried with some other as you
mentioned but no luck, In short Apache SubProcess is not working for me,
Even the example that's mentioned in the website, May be I am missing
something very basic, Any help??

Thanks,


-----Original Message-----
From: Scott Gifford [mailto:sgifford@suspectclass.com] 
Sent: Saturday, June 23, 2007 9:43 AM
To: Sajid Khan (WT01 - Computing, Storage & Software Products)
Cc: modperl@perl.apache.org
Subject: Re: Apache Subprocess

<kh...@wipro.com> writes:

> Hi Scott,
>
> I do not see anything in error log, The print line before and after 
> the command also works fine,The webserver has permission to run the 
> command since I can execute the same command using backtick like 
> `/tmp/in_out_err.pl`

Huh, that is very odd.  Are you sure the program is not getting executed
at all?  Is it possible it's just not getting its input or sending its
output because of buffering?  What if instead of that program you run
something like "/bin/echo Test"?

> Do we need to configure anything so that apache can start executing 
> the Apache::SubProcess package ?

Well, you will need to say "use Apache::SubProcess", but I assume you
would get a compile-time error if you didn't do that.

-----Scott.


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
 
www.wipro.com

Re: Apache Subprocess

Posted by Scott Gifford <sg...@suspectclass.com>.
<kh...@wipro.com> writes:

> Hi Scott,
>
> I do not see anything in error log, The print line before and after the
> command also works fine,The webserver has permission to run the command
> since I can execute the same command using backtick like
> `/tmp/in_out_err.pl`

Huh, that is very odd.  Are you sure the program is not getting
executed at all?  Is it possible it's just not getting its input or
sending its output because of buffering?  What if instead of that
program you run something like "/bin/echo Test"?

> Do we need to configure anything so that apache can start executing the
> Apache::SubProcess package ?

Well, you will need to say "use Apache::SubProcess", but I assume you
would get a compile-time error if you didn't do that.

-----Scott.

RE: Apache Subprocess

Posted by kh...@wipro.com.
Hi Scott,

I do not see anything in error log, The print line before and after the
command also works fine,The webserver has permission to run the command
since I can execute the same command using backtick like
`/tmp/in_out_err.pl`
Do we need to configure anything so that apache can start executing the
Apache::SubProcess package ?

Thanks,
Sajid
-----Original Message-----
From: Scott Gifford [mailto:sgifford@suspectclass.com] 
Sent: Thursday, June 21, 2007 11:32 PM
To: Sajid Khan (WT01 - Computing, Storage & Software Products)
Cc: modperl@perl.apache.org
Subject: Re: Apache Subprocess

Hi Khan,

<kh...@wipro.com> writes:

[...]

> I was trying in the lines of below code from 
> http://perl.apache.org/docs/2.0/ api/Apache/SubProcess.html .
>  
>   # write to/read from the process
>   $command = "/tmp/in_out_err.pl";
>   ($in_fh, $out_fh, $err_fh) = $r->spawn_proc_prog($command);
>   print $in_fh "hello\n";
>   $output = read_data($out_fh);
>   $error  = read_data($err_fh);

I've not used this particular function before, but a few ideas that
might help: Do you see anything in your error log?  If you put a print
line before and after running the command, do you see either of them?
Does the Web server user have permission to run the command?  Is
autoflush turned on for $in_fh?  Does the running program flush its
output immediately?

Good luck!

----Scott.


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
 
www.wipro.com

Re: Apache Subprocess

Posted by Scott Gifford <sg...@suspectclass.com>.
Hi Khan,

<kh...@wipro.com> writes:

[...]

> I was trying in the lines of below code from http://perl.apache.org/docs/2.0/
> api/Apache/SubProcess.html .
>  
>   # write to/read from the process
>   $command = "/tmp/in_out_err.pl";
>   ($in_fh, $out_fh, $err_fh) = $r->spawn_proc_prog($command);
>   print $in_fh "hello\n";
>   $output = read_data($out_fh);
>   $error  = read_data($err_fh);

I've not used this particular function before, but a few ideas that
might help: Do you see anything in your error log?  If you put a print
line before and after running the command, do you see either of them?
Does the Web server user have permission to run the command?  Is
autoflush turned on for $in_fh?  Does the running program flush its
output immediately?

Good luck!

----Scott.

RE: Apache Subprocess

Posted by kh...@wipro.com.
Any reply on this, I am literally struct. Please let me know your ideas
 
-Sajid


 
Hi Folks,
 
I was trying in the lines of below code from http://perl.apache.org/docs/2.0/api/Apache/SubProcess.html .
 
  # write to/read from the process
  $command = "/tmp/in_out_err.pl";
  ($in_fh, $out_fh, $err_fh) = $r->spawn_proc_prog($command);
  print $in_fh "hello\n";
  $output = read_data($out_fh); 
  $error  = read_data($err_fh);
 
The sub process(C program in my case) is never invoked and both input and output streams are empty. Can you please tell me what might be going wrong. I am using mod perl 2
 
Thanks,

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com <http://www.wipro.com/> 
	



The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
 
www.wipro.com