Hey all, doing what I thought was going to be a quick little CGI to view log info...HA!
Trying to list the files in a directory on a mapped drive. opendir(...) is resulting in error 'No such file or directory'. The path works when the drive is local (e.g. c:/logfiles/monitor), but returns the above error when the drive is mapped (e.g. z:/logfiles/monitor).
System running this CGI is Win XP Pro and mapped drives are Win XP Pro ad Win2k server...all NTFS.
I've included the code in case yas feel like looking and telling me where I've gone wrong. After staring at this script all day (15 minutes writing and 5 hours staring and drooling.). :P
Any help would be appreciated.
#! perl -wT
use CGI;
use strict;
my $cgi = new CGI;
my $dir = $cgi->param("server");
print $cgi->header();
print <<END;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1
+">
<title>Logs</title>
</head>
<body bgcolor="#e7e7e7" text="#000000" link="#1346ad" alink="#1346ad"
+vlink="#1346ad">
<font face="Arial">
END
# ADD SERVER NAMES AND PATHS TO THIS CONIDTION BLOCK
if($dir eq 'server1') {
$dir = 'z:/logfiles/monitor';
} elsif($dir eq 'server2') {
$dir = 'y:/logfiles/monitor';
}
print "<b><u>", $cgi->param("server"), " logfiles at $dir</u></b><br>"
+;
# GET ALL CONTENTS OF THE DIRECTORY
opendir(DIR, $dir) || print "<font color=\"#ff0000\">Problem: <i>$!</i
+></font>";
while(my $file = readdir(DIR)) {
# IF NOT A DIRECTORY, PRINT FILENAME
if(!-d "$dir/$file") {
print "<a href=\"/cgi-bin/admin/displayLog.pl?file=$dir/$file\
+">$file</a><br>";
}
}
closedir(DIR);
print "</font>";
print $cgi->end_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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.