Hi Monks!

I am trying to write cgi script that will list the contents of my external harddrive.

Here's what I got so far and it works from the command line.

#!/usr/bin/perl -w use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $EX_DIR = "/media/EXTERNAL"; sub displayHardDriveFiles () { opendir( DIR, $EX_DIR ) || die "<H3>Cannot open $EX_DIR: $!</ +H3>\n"; print <<HTML; <table border=1> <tr><th>Files on this harddrive</th></tr> HTML foreach my $d (sort readdir(DIR)) { print "<tr><td>$d</td></tr>\n"; } print <<HTML; </table> HTML } print header; print start_html ("Welcome"); displayHardDriveFiles(); print end_html;
But when I run it in the browser I get ...
Software error: <H3>Cannot open /media/EXTERNAL: Permission denied</H3> For help, please send mail to the webmaster (root@localhost), giving t +his error message and the time and date of the error.
What am I doing wrong? Is there some change I need to make to my httpd.conf and if what would that be? Thanks!

Edit: g0n - replaced pre tags with code tags


In reply to A CGI script to list the files on my external harddrive by Anonymous Monk

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.