http://qs321.pair.com?node_id=583882

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

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