I am getting the following error:
syntax error at ./viewlog.cgi line 54, near "while"
syntax error at ./viewlog.cgi line 57, near "}"
Execution of ./viewlog.cgi aborted due to compilation errors.
for this code:
#!/usr/bin/perl -wT
use strict;
use Cwd;
## taint environmentals
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
$ENV{'PATH'} = "/usr/bin:/usr/local/bin";
## cgi.pm
use CGI;
$CGI::DISABLE_UPLOADS = 1;
$CGI::POST_MAX = 1024;
my $query = new CGI;
## config vars
my $rcs = (qw$Revision: 1.13 $)[-1];
my $cwd = cwd();
my $domain = (split(/\//,$cwd))[-1];
my %logfile = ( wwwlog => "/var/log/www/www-xfer.$domain",
wwwerr => "/var/log/www/www-error.$domain",
ftplog => "/var/log/ftp/ftp-xfer.$domain",
ftperr => "/var/log/ftp/ftp-error.$domain",
ssllog => "/var/log/ssl/ssl-xfer.$domain",
sslerr => "/var/log/ssl/ssl-error.$domain"
);
## get form input
my $log = $query->param('log') || '';
## create html
print <<HTML
Content-type: text/html\n\n
<html>
<head><title>View Log Files</title></head>
<body>
<base href="https://www.$domain/">
<form action="controlpanel/viewlog.cgi" method="post">
<select name="log">
<option value="wwwlog">HTTP Traffic Log
<option vlaue="wwwerr">HTTP Error Log
<option value="ssllog">SSL Traffic Log
<option value="sslerr">SSL Error Log
<option value="ftplog">FTP Transfer Log
<option value="ftperr">FTP Error Log
</select>
<input type="submit" value="Display Log">
</form>
<p>
HTML
if ($log) {
open(LOG, ($logfile{$log}));
while (<LOG>) {
chomp $_;
print "$_\n";
}
close(LOG);
}
print <<HTML
<p>
</body>
</html>
HTML
The errors seem to come up from within the whileloop, however I am skeptical that this is actually the root of the cause. When I comment out the entire loop, I see another error complaining about the last HERE doc. However when, I comment everything out from the while statement to the end of the file, the script seems to be happy. Any help is very appreciated.
humbly -c
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.