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

I have a script
#!/Perl/bin/perl use CGI; $tracking = new CGI; print $tracking->header(); print $tracking->start_html(); opendir(TRACKING, "R:\\"); @test = readdir TRACKING; print @test; print $tracking->end_html;
its very basic.... and when I call this opendir in console mode it works.. but in CGI mode it fails... So my thought was ... the webserver doesn't know what the R:\ drive is .. it can only open files in the \htdocs folder of apache or .. \cgi-bin..... is that correct? or is there a way around it. I don't want to move the data... because it needs to be where it is... I'm just trying to build a web interface to it.

Replies are listed 'Best First'.
Re: using opendir in CGI
by particle (Vicar) on Jun 20, 2003 at 13:50 UTC

    always check the error code from open and opendir!

    use CGI::Carp ':fatalsToBrowser'; ##... opendir(TRACKING, 'R:\\') or die "cannot open directory: $!";

    ~Particle *accelerates*

Re: using opendir in CGI
by adrianh (Chancellor) on Jun 20, 2003 at 13:53 UTC

    Why don't you get Perl to tell you why it isn't working? Just change:

    opendir(TRACKING, "R:\\");

    to

    opendir(TRACKING, "R:\\") or die "could not opendir because $!";

    Always check the results from system commands - it saves time in the long run :-)

      Thank you .. I didn't know I could do that. it says .. no such file or directory.. .which may prove my earlier theory that it doesn't know about anything outside of the webserver directory context.