[Xitami] CGI Scripting
David Lambert
xitami@lists.xitami.org
Sat, 3 Nov 2001 13:06:11 -0000
Thanks you all for the replies, including those concerning the disclaimer.
It's part and parcel of living in the UK now, where privacy laws are under
considerable threat. Our govt. likes to snoop, so does your but they haven't
told you yet!
Anyway, I digress. It turns out that all I needed to do was to add the
following to read the working directory of the initiating script i.e.
$DocRoot = $ENV{'DOCUMENT_ROOT'};
Then by appending this to the 'open(script)' command it worked OK.
Please forgive the coding samples, I only started on Perl a couple of weeks
ago. Lots to learn still... but such a powerful language.
Regards & Thanks
David
-----Original Message-----
From: xitami-admin@lists.xitami.org
[mailto:xitami-admin@lists.xitami.org]On Behalf Of David Lambert
Sent: 26 October 2001 15:23
To: dlamb@tech-app.co.uk
Subject: [Xitami] CGI Scripting
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
Xitami Users Mailing List -- For Xitami support
To unsubscribe: http://lists.xitami.org/mailman/listinfo/xitami
"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