I am learning CGI programming and have found the following script. I am getting the error :
Content-Type: text/html; charset=ISO-8859-1
Cannot open C:/Perl/Sample_Scripts/guestbook: No such file or directory at helpd
esk.cgi line 33.
when I run the following script:
#!/usr/bin/perl -wT
use strict;
use CGI qw
all);
use Fcntl qw
flock);
# Location of the guestbook log file. Change this to suit your needs
my $gbdata="C:/Perl/guestbook";
my $semaphore="..../helpdesk.sem";
# Function to lock (waits indefinitely)
sub get_lock {
open(SEM, ">$semaphore")|| die "Cannot create semaphore: $!";
flock SEM, LOCK_EX;
}
# Function to unlock
sub release_lock {
close(SEM);
}
# This function saves a passed-in help desk HTML form to a file
sub save {
get_lock();
open(GB, ">$gbdata") || die "Cannot open $gbdata: $!";
print GB "name: ", param('name'), "\n";
print GB "type: ", param('probtype'), "\n";
print GB "problem: ", param('problem'), "\n";
close(GB);
release_lock();
}
# This function displays the contents of the help desk log file as HTML,
# with minimal formatting.
sub display {
open(GB, $gbdata) || die "Cannot open $gbdata: $!";
while(<GB>){
print "<b>$_</b><br />"; # The name
my($type,$prob);
$type=<GB>;
$prob=<GB>;
print "$type<br />";
print "$prob<br /><br />";
}
close(GB);
}
print header;
# The parameter 'submit' is only passed if this CGI program was
# executed by pressing the 'submit' button in the form
if (defined param('submit')) {
save;
display;
} else {
display;
}
Any ideas? Why is the file not begin created I have done this loads of times no problem.
Content-Type: text/html; charset=ISO-8859-1
Cannot open C:/Perl/Sample_Scripts/guestbook: No such file or directory at helpd
esk.cgi line 33.
when I run the following script:
#!/usr/bin/perl -wT
use strict;
use CGI qw
use Fcntl qw
# Location of the guestbook log file. Change this to suit your needs
my $gbdata="C:/Perl/guestbook";
my $semaphore="..../helpdesk.sem";
# Function to lock (waits indefinitely)
sub get_lock {
open(SEM, ">$semaphore")|| die "Cannot create semaphore: $!";
flock SEM, LOCK_EX;
}
# Function to unlock
sub release_lock {
close(SEM);
}
# This function saves a passed-in help desk HTML form to a file
sub save {
get_lock();
open(GB, ">$gbdata") || die "Cannot open $gbdata: $!";
print GB "name: ", param('name'), "\n";
print GB "type: ", param('probtype'), "\n";
print GB "problem: ", param('problem'), "\n";
close(GB);
release_lock();
}
# This function displays the contents of the help desk log file as HTML,
# with minimal formatting.
sub display {
open(GB, $gbdata) || die "Cannot open $gbdata: $!";
while(<GB>){
print "<b>$_</b><br />"; # The name
my($type,$prob);
$type=<GB>;
$prob=<GB>;
print "$type<br />";
print "$prob<br /><br />";
}
close(GB);
}
print header;
# The parameter 'submit' is only passed if this CGI program was
# executed by pressing the 'submit' button in the form
if (defined param('submit')) {
save;
display;
} else {
display;
}
Any ideas? Why is the file not begin created I have done this loads of times no problem.