You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Tim Wood <tw...@gmail.com> on 2006/08/16 15:20:24 UTC

[users@httpd] piped log not getting any stdin

Hi,
I'm trying to pipe my Apache 2.0.54 logs to a script, but never seem
to get any logs sent through the pipe.

Apache starts my script (actually a python program) which runs fine
until it tries to read a log from stdin.  At that point the script
hangs and never gets any input.

My script works correctly for other sources, ie: "cat access.log |
script.py" works correctly.

Also, I tried just piping apache logs to cat, ie:

CustomLog "|/bin/cat >> /var/log/apache2/test.log" common

I get this is my error.log:

piped log program ' /bin/cat >> /var/log/apache2/test.log' failed unexpectedly
/bin/cat: >>: No such file or directory


Quite a few people in the past seem to have trouble having their
scripts get any input from apache2, but I couldn't find any solutions
in the lists....  Any ideas?

thanks
-Tim

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] piped log not getting any stdin

Posted by Tim Wood <tw...@gmail.com>.
On 8/16/06, Joshua Slive <jo...@slive.ca> wrote:
> On 8/16/06, Tim Wood <tw...@gmail.com> wrote:
> > Hi,
> > I'm trying to pipe my Apache 2.0.54 logs to a script, but never seem
> > to get any logs sent through the pipe.
> >
> >
> > piped log program ' /bin/cat >> /var/log/apache2/test.log' failed unexpectedly
> > /bin/cat: >>: No such file or directory
>
> The piped log program must be an executable command with possible
> arguments, not something that you would pass to the shell.  So if you
> made a shell script containing
> #!/bin/sh
> /bin/cat >> /var/log/apache2/test.log
>
> and then used the shell script as the target, you would have more luck.
>
> Have you tried the python equivalent of a trivial program that simply
> pipes the log entries to a file?  What does it look like?
>
> Joshua.

Good point on why straight out "cat" didn't work, but I just tried
using your mini cat script and that doesn't write anything to the log
either.

Thinking maybe python was causing me trouble, I also tried this perl script:
(copied from http://www.sudleyplace.com/pipederrorlogs.html)
-------------
#!/usr/bin/perl

$|=1; # Use unbuffered output
print while <STDIN>;
-------------
I don't get any output from that either.

Note that having apache write the logs directly works fine, it is only
a problem when I try to use a pipe.

Any other ideas?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] piped log not getting any stdin

Posted by Joshua Slive <jo...@slive.ca>.
On 8/16/06, Tim Wood <tw...@gmail.com> wrote:
> Hi,
> I'm trying to pipe my Apache 2.0.54 logs to a script, but never seem
> to get any logs sent through the pipe.
>
> Apache starts my script (actually a python program) which runs fine
> until it tries to read a log from stdin.  At that point the script
> hangs and never gets any input.
>
> My script works correctly for other sources, ie: "cat access.log |
> script.py" works correctly.
>
> Also, I tried just piping apache logs to cat, ie:
>
> CustomLog "|/bin/cat >> /var/log/apache2/test.log" common
>
> I get this is my error.log:
>
> piped log program ' /bin/cat >> /var/log/apache2/test.log' failed unexpectedly
> /bin/cat: >>: No such file or directory

The piped log program must be an executable command with possible
arguments, not something that you would pass to the shell.  So if you
made a shell script containing
#!/bin/sh
/bin/cat >> /bar/log/apache2/test.log

and then used the shell script as the target, you would have more luck.

Have you tried the python equivalent of a trivial program that simply
pipes the log entries to a file?  What does it look like?

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org