[Xitami] CGI Scripting

David Lambert xitami@lists.xitami.org
Fri, 26 Oct 2001 15:22:33 +0100


I have a Perl script in webroot/cgi-bin, which reads a text file in and
outputs it in HTML format to the requesting browser (see smaple script
below). Well, that's what it's supposed to do.

It works at the DOS prompt, opening the file and printing output to the
screen. However, if I try the script through a browser, the server returns
no file contents. I assumed the problem was a permissions error, so as a
brute force resolution, I gave Everyone, Full Permissions to the cgi-bin
directory, which still doesn't work.

The Xitami server itself is running under the NT Administrator user, so
should definitely be included in the Everyone group and have full
permissions to all files on the local machine. The working dir. is set to
"-" as recommended, yet it manages to create temporary files in D:\Temp,
which contain the output sent to the screen. So why can't it read in the
files?
-------------------------------------------------------------------------
Sample Script:

#!perl

# Define Variables
	$Script;
	$lines;

# Read Name of Script
	$Script = $ENV{'SCRIPT_NAME'};
	if ($Script eq "") {$Script = "default.txt"};

# Open Script
	open(TXT, "<".$Script);
	@text=<TXT>;
	close(TXT);

# Print Script to screen
	&Header;
	print "\nScript to be processed: <b>".$Script."</b><hr>";
	foreach $line(@text){
		print "$line.<br>";
		$lines++;
	}
	if($lines<1){$lines="no"};
	&Footer;

sub Header{
	print "content-type:text/html\n\n<html>";
	print "<title>View File Script</title>";
}

sub Footer{
	print "There are <b>".$lines."</b> lines<br>";
	print "<b>The End</b>";
	print "</html>";
}
#	End viewfile.pl


"This e-mail communication may be intercepted for regulatory, quality
control, or crime detection purposes as per the UK Government Regulation of
Investigatory Powers (RIP) Act. This message is intended only for the use of
person(s) ("the Intended Recipient") to whom it is addressed. It may contain
information that is privileged and confidential. Accordingly any dissemination, distribution, copying or
other use of this message or any of its content by any other person may
constitute a breach of civil or criminal law and is strictly prohibited. If
you are not the Intended Recipient please contact the sender as soon as
possible. Any views expressed in this message are those of the individual
sender and may not necessarily reflect the views of Technical Approach."
All enquiries should be directed to postmaster@tech-app.co.uk