solarity has asked for the wisdom of the Perl Monks concerning the following question:
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>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: perl stdout and backtick execute
by dasgar (Priest) on Oct 25, 2013 at 00:13 UTC | |
Re: perl stdout and backtick execute
by sundialsvc4 (Abbot) on Oct 25, 2013 at 00:16 UTC | |
by solarity (Initiate) on Oct 25, 2013 at 14:28 UTC | |
Re: perl stdout and backtick execute
by Eily (Monsignor) on Oct 25, 2013 at 08:50 UTC |
Back to
Seekers of Perl Wisdom