HP3000-L Archives

November 1997, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Bixby <[log in to unmask]>
Reply To:
Date:
Wed, 12 Nov 1997 13:38:35 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (64 lines)
Raymond Roesch writes:
>
> Mark
>
> With sh.hpbin.sys I did the following:
> Server/MANAGER.SYS (7) : run sh.hpbin.sys
>
> $ cd /APACHE/PUB/cgi-bin
> $ sj.pl
> This works correctly.

I think I have this one figured out.  When you run sj.pl from the command line
above, it appears to work correctly.  But then try the following:

        sj.pl >junk.stdout 2>junk.stderr

The junk.stderr file will be empty as expected.  But junk.stdout will contain
the showjob output first, followed by all of the HTML, and this will confuse
the web server.

The reason this happens is that by default Perl buffers all output.  I
haven't looked at the source to confirm this, but I'm guessing that Perl is
smart enough that if you're printing to a terminal, it will flush the buffers
before calling system() because your system command might also be generating
terminal output.  But in the case where you're printing to disk, or to a pipe
as a web server CGI, the pre-system() flush doesn't happen.

The solution to this problem is to tell Perl to not buffer output:

        $| = 1;
        or
        $OUTPUT_AUTOFLUSH = 1;

Add one of those two lines to the beginning of this sample CGI and it will
work correctly.

> #!/bin/perl
> #
> # print your HTTP headers here
> #
>
> print 'Content-type: text/html
>
> <HTML>
> <HEAD>
> <TITLE>Title</TITLE>
> </HEAD>
> <BODY>
> <H1>jobs</H1>
> <PRE>
> ';
> system( "callci sj" );
> print '
> </PRE>
> </BODY>
> </HTML>
> ';
--
Mark Bixby                      E-mail: [log in to unmask]
Coast Community College Dist.   Web: http://www.cccd.edu/~markb/
District Information Services   1370 Adams Ave, Costa Mesa, CA, USA 92626-5429
Technical Support               +1 714 438-4647
"You can tune a file system, but you can't tune a fish." - tunefs(1M)

ATOM RSS1 RSS2