Re: Client filehandle?
On Wed, 2 Aug 2000, Todd Caine wrote: > > STDOUT is where $r->print goes under mod_perl; you should be OK. > > The data that is printed out via $r->print is on the file descriptor that the > http request is set up on. If the HTTP request came in on file descriptor 3 > then $r->print('foo') prints to file descriptor 3; not stdout(file descriptor > 1, on my system). right, Perl STDOUT != C stdout > The only way I can get part of gif to the browser was to do this: > > my $c = $r->connection; > my $fd_num = $c->fileno(0); > open(STDOUT, ">&$fd_num"); > RRDs::graph($args); > > But the data is incomplete. Even when I autoflush the $fd_num. > There has got to be a better way. see Apache::Magick in the eagle book or at modperl.com. it's still ugly since it writes to a tmpfile, but it works. you can also modify your c sources to redfine stdout-ish calls, Apache::Peek does something like that for redirecting stderr to the client socket: #define PerlIO request_rec #define PerlIO_printf rprintf #define PerlIO_vprintf(r,fmt,vlist) \ vbprintf(r->connection->client, fmt, vlist) #define PerlIO_stderr() perl_request_rec(NULL) #define PerlIO_putc(r,c) rputc(c,r) #define PerlIO_puts(r,s) rputs(s,r)
RE: Client filehandle?
> -Original Message- > From: Douglas Wilson [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 02, 2000 3:24 PM > To: Todd Caine; mod_perl > Subject: RE: Client filehandle? > Maybe (and I mean MAYBE): > local *STDOUT = \*$r; And of course, that should have been (hey I'm making it up & learning as I go along): local *STDOUT = $r; HTH, Douglas Wilson
RE: Client filehandle?
> -Original Message- > From: Todd Caine [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 02, 2000 1:30 PM > To: mod_perl > Subject: Client filehandle? > > > I've got a Perl Module which has a function called > RRDs::graph($args), that will only print to stdout. In my > handler I write something similar to: > > sub handler { > my $r = shift; > > # I want the output to go to the client, ($r->print()), > but instead it will only go to STDOUT > So I was trying something like: > > *STDOUT = \*r{IO}; Maybe (and I mean MAYBE): local *STDOUT = \*$r; HTH, Douglas Wilson
Re: Client filehandle?
darren chamberlain wrote: > Todd Caine ([EMAIL PROTECTED]) said something to this effect: > > I've got a Perl Module which has a function called > > RRDs::graph($args), that will only print to stdout. In my > > handler I write something similar to: > > STDOUT is where $r->print goes under mod_perl; you should be OK. The data that is printed out via $r->print is on the file descriptor that the http request is set up on. If the HTTP request came in on file descriptor 3 then $r->print('foo') prints to file descriptor 3; not stdout(file descriptor 1, on my system). > > > Failing this, does RRDs::graph print explicitly to STDOUT, or just to > the currently selected filehandle? If the latter (it probably is), > just select a a different filehandle, and then call &graph. > RRDs::graph is perl wrapper for the RRDTool utility written in C. It explicitly prints to 'stdout'. I've tried selecting on a different file descriptor like this: my $c = $r->connection; my $fd_num = $c->fileno(0); select($fd_num); And I get "The document contained no data". The only way I can get part of gif to the browser was to do this: my $c = $r->connection; my $fd_num = $c->fileno(0); open(STDOUT, ">&$fd_num"); RRDs::graph($args); But the data is incomplete. Even when I autoflush the $fd_num. There has got to be a better way. Thanks for your thoughts, Todd > > (darren) > > -- > Without deviation from the norm, 'progress' is not possible. -- Frank Zappa -- -- --
Re: Client filehandle?
Todd Caine ([EMAIL PROTECTED]) said something to this effect: > I've got a Perl Module which has a function called > RRDs::graph($args), that will only print to stdout. In my > handler I write something similar to: STDOUT is where $r->print goes under mod_perl; you should be OK. Failing this, does RRDs::graph print explicitly to STDOUT, or just to the currently selected filehandle? If the latter (it probably is), just select a a different filehandle, and then call &graph. (darren) -- Without deviation from the norm, 'progress' is not possible. -- Frank Zappa