What would cause a perl script to behave differently in different directories on one system? The system is running RedHat 3.4.3-9, and perl version 5.8.5.

The following perl script runs correctly when run from /home/test. After copying this script to /var/www/cgi-bin, it runs wrong: 1) Its stdout is directed somewhere other than back to the user, and 2)It does not receive the output from the call to pread.

Here is the perl script:

#!/usr/bin/perl my @cc = (); @cc = `pread cm 98`; print "Content-type: text/html\n\n"; print <<HTML; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML lang='en'> <HEAD> <TITLE> Hello World Status </TITLE> </HEAD> <BODY> hello world: $cc[0] </BODY> </HTML> HTML _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ When run from the directory /home/test as [xyz@daystar test]$ ./tst.pl the output is correct: Content-type: text/html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML lang='en'> <HEAD> <TITLE> Hello World Status </TITLE> </HEAD> <BODY> hello world: RETAIL WEBSALE </BODY> </HTML> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ There is no output when run from directory /var/www/cgi-bin as [xyz@daystar test]$ ./tst.pl _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ However, when run and piping output to 'more' using the command [xyz@daystar test]$ ./tst.pl | more the output is: Content-type: text/html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML lang='en'> <HEAD> <TITLE> Hello World Status </TITLE> </HEAD> <BODY> hello world: </BODY> </HTML>

In reply to perl stdout and backtick execute by solarity

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.