danni.bayn16
New Member
- Messages
- 2
- Reaction score
- 0
- Points
- 0
Hi all,
I have a perl/CGI script that I'm trying to use to write form data to a file. The script and the form seem to be working fine (confirmation and error pages are being displayed correctly), other than the data_file is not being created/written to.
This line:
open OUT, ">/home/feam/Data/data_hold.txt" || die "Can't open for writing: $!";
isn't working.
I've tried changing the path to the tmp and cgi-folder and have tried variations of relative rather than full path names. In each case, the confirmation page is shown correctly and all of my error and access logs are blank.
This script worked fine when I was doing my own hosting, but I am unfamiliar with how 3rd party hosting handles file permissions, scripting, etc.
Any help would be greatly appreciated!
Thanks,
danni
---------------------------------------
#!/usr/bin/perl -w
use Fcntl qwflock :seek);
my $time = localtime;
my $remote_id = $ENV{REMOTE_HOST} || $ENV{REMOTE_ADDR};
my @name_value_pairs = split /&/, $ENV{QUERY_STRING};
my $NumRange = 10000;
my $RanNum = int(rand($NumRange));
if ($ENV{REQUEST_METHOD} eq 'POST') {
my $query = "";
read(STDIN, $query, $ENV{CONTENT_LENGTH} ) == $ENV{CONTENT_LENGTH};
push @name_value_pairs, split /&/, $query;
}
foreach $pair(@name_value_pairs) {
($name, $value) = split(/=/, $pair);
$FORM{$name} = $value;
}
if (!$FORM{'name'}) {
print "Content-type: text/html\n\n";
print "<head><title>Error: MISSING NAME</title></head>";
print "<body><p>You must enter a name to submit this form</p>";
print "<p>Please use the Back button to enter your name and resubmit</p>";
print "</body>";
print "</html>";
}
else {
open OUT, ">/home/feam/Data/data_hold.txt" || die "Can't open for writing: $!";
flock(OUT, LOCK_EX);
seek(OUT, 0, 2);
print OUT "hold\n";
foreach(@name_value_pairs) {
print OUT "$_\n";
}
print "Content-type: text/html\n\n";
print <<END_OF_PAGE;
<html>
<head><title>Thank you!</title></head>
<body>Thank you for completing your alignment judgements. </p>
</body>
</html>
END_OF_PAGE
}
I have a perl/CGI script that I'm trying to use to write form data to a file. The script and the form seem to be working fine (confirmation and error pages are being displayed correctly), other than the data_file is not being created/written to.
This line:
open OUT, ">/home/feam/Data/data_hold.txt" || die "Can't open for writing: $!";
isn't working.
I've tried changing the path to the tmp and cgi-folder and have tried variations of relative rather than full path names. In each case, the confirmation page is shown correctly and all of my error and access logs are blank.
This script worked fine when I was doing my own hosting, but I am unfamiliar with how 3rd party hosting handles file permissions, scripting, etc.
Any help would be greatly appreciated!
Thanks,
danni
---------------------------------------
#!/usr/bin/perl -w
use Fcntl qwflock :seek);
my $time = localtime;
my $remote_id = $ENV{REMOTE_HOST} || $ENV{REMOTE_ADDR};
my @name_value_pairs = split /&/, $ENV{QUERY_STRING};
my $NumRange = 10000;
my $RanNum = int(rand($NumRange));
if ($ENV{REQUEST_METHOD} eq 'POST') {
my $query = "";
read(STDIN, $query, $ENV{CONTENT_LENGTH} ) == $ENV{CONTENT_LENGTH};
push @name_value_pairs, split /&/, $query;
}
foreach $pair(@name_value_pairs) {
($name, $value) = split(/=/, $pair);
$FORM{$name} = $value;
}
if (!$FORM{'name'}) {
print "Content-type: text/html\n\n";
print "<head><title>Error: MISSING NAME</title></head>";
print "<body><p>You must enter a name to submit this form</p>";
print "<p>Please use the Back button to enter your name and resubmit</p>";
print "</body>";
print "</html>";
}
else {
open OUT, ">/home/feam/Data/data_hold.txt" || die "Can't open for writing: $!";
flock(OUT, LOCK_EX);
seek(OUT, 0, 2);
print OUT "hold\n";
foreach(@name_value_pairs) {
print OUT "$_\n";
}
print "Content-type: text/html\n\n";
print <<END_OF_PAGE;
<html>
<head><title>Thank you!</title></head>
<body>Thank you for completing your alignment judgements. </p>
</body>
</html>
END_OF_PAGE
}