chrismassey
Programmer
Hi,
I have a simple script which is designed to take the value from a textbox, combine it with the path and to open that directory. I recieve an Error 500 and i'm not sure why...
Thanks in advance
Chris
I have a simple script which is designed to take the value from a textbox, combine it with the path and to open that directory. I recieve an Error 500 and i'm not sure why...
Code:
########## Opening Tags
#! /usr/bin/perl
use strict;
########## Declare variables
my ($initial_path, $open1, $open2, $openb1, $openb2, $path, @directory_contents1, @directory_contents2);
########## Connect to form
##### Path textboxes
$open1 = param('open1');
$open2 = param('open2');
##### Path open buttons
$openb1 = param('openb1');
$openb2 = param('openb2');
######### Path to z directory
$initial_path = "/PATH/ChrisMassey.co.uk/Perl/Scripts/ControlPanelV1.0/Test";
########## Check which open button was pressed
if ($openb1) {
##### The path is...
$path = "$initial_path . ' ' . $open1";
}
else {
##### The path is...
$path = "$initial_path . ' ' . $open1 . ' ' . $open2";
}
########## Open directory
opendir (LOGDIR, "$path") || Error ('open', 'directory');
@directory_contents1 = readdir (LOGDIR);
closedir (LOGDIR);
##### Sort contents into alphabetical order
@directory_contents2 = sort @directory_contents1;
########## Print contents
##### Print form at the top
print "Content-type: text/html\n\n";
print <<"HTML code";
<HTML>
<HEAD>
<TITLE>Webspace Explorer Control Panel</TITLE>
</HEAD>
<BODY>
<FORM ACTION="script.pl" METHOD=POST>
<p><input type="text" name="open1" size="50"><input type="submit" value="Open" name="openb1"></p>
<p><input type="text" name="open2" size="50"><input type="submit" value="Open" name="openb2"></p>
</FORM>
</BODY>
</HTML>
HTML code
##### Print directory contents beneath
foreach (@directory_contents2) {
print "Content-type: text/html\n\n";
print "$_";
}
########## File opening error
sub Error {
print "Content-type: text/html\n\n";
print "<font face=arial size=2><P>Cannot Open File/Directory... Error 1.</font>";
exit;
}
Thanks in advance
Chris