I've got a cgi script written in perl and I'm attempting to write data to a file but it isn't working
#!/usr/bin/perl -w
&print_HTTP_header;
&print_head;
&print_body;
&print_tail;
sub print_HTTP_header
{
print "Content-type: text/html\n\n";
}
# ---- print HTML stuff at head
sub print_head
{
print <<END;
<HTML><HEAD>
<TITLE>test script</TITLE>
<BODY bgcolor="#ffffff" text="#000000">
<H4>test script</H4>
END
}
sub print_body
{
use IO::File;
use Fcntl ":flock";
open (MYFILE, ">>../data.txt");
flock MYFILE, LOCK_SH;
print MYFILE "Matthias\nLucius\nKadmiel\nAradiel\nEzekiel\nOctavius\n";
close (MYFILE);
open (INPUT, "<../data.txt");
$variable = <INPUT>;
while(<INPUT>)
{
print $_;
}
}
sub print_tail
{
print "<BR><BR>";
print "</BODY></HTML>";
}
Basically I've got this script on my university server running unix, under my account. I've verified the perl address is correct as well.
It's located under the cgi-bin folder and all I need to do is just call http://WWW.....cgi-bin/test/write.cgi (is the name of the file) and it should keep appending the names into a file and then display the result.
I've uploaded an empty data.txt file one level up from the test folder (ie. placed into cgi-bin).
So now when I run the script, absolutely nothing happens to the file and all i get is "test script" printed out (in H4).
I've set every single file permission to 777 (highest possible for every user) and it still doesn't work.
I went and uploaded the same files to my own server and it works fine so now I have no idea what's going on.
Not sure if my script has been written correctly or not, so some help would be most appreciated.

New Topic/Question
Reply



MultiQuote






|