Hi John,
Thanks for the Email. I had thought about the paths. I just tried it and it
makes no difference.
Regards
Richard
JK> Hi ,
JK> I am no expert but I would guess that cgi runs in a restricted environment
JK> and doesn't have a full PATH, thus it doesn't know how to call tail and
JK> tac.
JK> I'd try putting the full path to these in the script.
JK> /usr/bin/tail
JK> /usr/bin/tac
JK> instead of just tail and tac.
JK> HTH, if not I am sure some guru will set you (and me) straight.
JK> cheers
JK> johnk
JK> On Wed, 25 Oct 2006, Richard Luckhurst wrote:
>> Hi All
>>
>> I have a simple perl cgi script that works fine and produces the correct
>> output
>> when run from a command line. However when called as a cgi script from
>> within a
>> web page the script does not run correctly.
>>
>> The script is called log-errors and is called as follows
>>
>> log-errors?domain=www.resmaster.com
>>
>> The script is as follows
>>
>> #!/usr/bin/perl
>> #
>>
>> use strict;
>> use warnings;
>>
>> use CGI qw/:standard -no_xhtml/;
>>
>> my $domain = param('domain');
>> my $tail = `tail -n2000 /var/log/httpd/$domain-error_log 2>/dev/null | tac`;
>> $tail =~ s/</</g;
>> $tail =~ s/>/>/g;
>>
>> print header;
>>
>> print start_html (
>> -title => 'Exodus Web Server Log',
>> -lang => 'en-UK',
>> -link => 'blue',
>> -vlink => 'blue');
>>
>> print font({size => 4}, b("Last 2000 Lines of the Error log for: $domain")),
>> br, "\n";
>> print font({size => 1}, br), "\n";
>> print 'Go to ', a({href => '#bottom'}, i('End of log')), br, br, "\n";
>> print pre($tail), "\n";
>> print a({name => 'bottom'}), br, "\n";
>> print b('End of log'), br, "\n";
>> print end_html, "\n\n\n";
>>
>>
>> I have tried putting a print statement in to see if the $domain variable gets
>> set and it does get set to www.resmaster.com. The print line also uses the
>> $domain variable and the correct thing is printed on the html page.
>>
>> The system command produces nothing, the $tail variable is empty, when run
>> as a
>> cgi script. When I run the script from a command line (and I force $domain
>> to be
>> www.resmaster.com as I can't pass it in) I find that the system call works
>> and I
>> get the data I would expect. In fact I left the $domain set to
>> www.resmaster.com
>> and tried running it as a cgi and I get nothing from the system call.
>>
>> I am using Apache 2.2 as my webserver and perl 5.8.8 both as they came with
>> Fedora core 5.
>>
>> Can anyone offer any suggestions about why this does not work?
>>
>> Regards
>>
>> Richard Luckhurst
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>