Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple CGI script query

Status
Not open for further replies.

tar565

Programmer
Jan 24, 2005
39
IE
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.
 
my $gbdata="C:/Perl/guestbook";
weird name for a file on Windows, but this is part of your problem

HTH
--Paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top