develooper Front page | perl.beginners | Postings from January 2002

RE: Cgi on IIS

Thread Previous | Thread Next
From:
Hanson, Robert
Date:
January 16, 2002 13:27
Subject:
RE: Cgi on IIS
Message ID:
11A304418ECBAB498FBF10ABCEA5E499D1CC8C@hq2kax1.nj.aptegrity.com

It's been a long time since I worked on IIS, but I believe the "Method not
allowed" error refers to GET, POST, PUT, and HEAD.  In IIS you can
allow/deny each of these, but I forget exactly where in the MMC that this
was located, it was with the file types.

So maybe ".cgi" doesn't have GET access (or whatever you are trying to do).
It could also be a permissions problem.  Make sure that the group "Everyone"
can write to the file (or at least the username that the web server uses
would need to)

Rob

-----Original Message-----
From: maureen [mailto:conlon434@home.com]
Sent: Wednesday, January 16, 2002 4:19 PM
To: Beginners CGI List; beginners@perl.org
Subject: Cgi on IIS



I hope someone can help me out.

I set up this cgi file and html form on a Unix server. The script
changes a user's password in a text file.

This works correctly on a Unix Server. However, I need to move these
files to an IIS server.
In testing on the IIS server,  I get an HTTP Error 405- Method not
allowed when the form is submitted. 

I did some research, but was unable to determine how to correct the
error. 

If anyone could help me out, I'd really appreciate it.

Thanks, Maureen

#!/usr/bin/perl
require "cgi-lib.pl";
#process incoming form data 
&ReadParse;
#set content type
print &PrintHeader;
#initialize variables
$pwfile =
"/data1/hypermart.net/worldwidewebstrategies/datafile/pwdata.txt";
$tmpfile =
"/data1/hypermart.net/worldwidewebstrategies/datafile/pwdata.tmp";
$lokfile =
"/data1/hypermart.net/worldwidewebstrategies/datafile/pwlock.fil";
#Print initial tags for web page
print "<HTML><BODY>\n";
#check for existence of password file
unless (-e $pwfile)
{ 
#password file doesn't exist!
#print message & shut down
print <<"PrintTag";
<H1>Sorry!</H1>
<P>$pwfile has't been uploaded to the
proper directory. Please contact the webmaster.</P>
</BODY>
</HTML>
PrintTag
exit(0);
}
#check for blank form fields
if ($in{'oldname'}eq"" || $in{'oldpw'}eq"")
{
#re-create form and shut down program
print <<"PrintTag";
<P><B>ERROR:</B> Please type your current username and
password in the spaces provided.</P>
<FORM
ACTION="http://server37.hypermart.net/worldwidewebstrategies/cgi-bin/changep
w.cgi"
METHOD="post">
<P>Your current username:<BR>
<INPUT TYPE="text" NAME="oldname" VALUE="$in{'oldname'}"></P>
<P>Your current password:<BR>
<INPUT TYPE="text"NAME="oldpw" VALUE="$in{'oldpw'}"></P>
<P>Your new password:<BR>
<INPUT TYPE="text" NAME="newpw1" VALUE="$in{'newpw1'}"></P>
<P>Type your new password again:<BR>
<INPUT TYPE="text" NAME="newpw2" VALUE="$in{'newpw2'}"></P>
<P>
PrintTag
if ($in{'delete'} eq "yes")
{
print "<INPUT TYPE=\"checkbox\" 
NAME=\"delete\" VALUE=\"yes\" CHECKED>\n";
}
else
{
print "\n";
}
print <<"PrintTag";
</P>
<INPUT TYPE="submit" VALUE="Change">
</FORM>
</BODY>
</HTML>
PrintTag
exit(0);  
} 
#make sure new passwords match 
if ($in{'newpw1'} ne $in{'newpw2'})
{ 
#re-create form and shut down program  
print <<"PrintTag";
<P><B>ERROR:</B> Your new passwords didn't match. 
You must type your new password exactly the same way twice. 
Please try again.</P>
<FORM
ACTION="http://server37.hypermart.net/worldwidewebstrategies/cgi-bin/changep
w.cgi"
METHOD="post">
<P>Your current username:<BR>
<INPUT TYPE="text" NAME="oldname" VALUE="$in{'oldname'}"></P>
<P>Your current password:<BR>
<INPUT TYPE="text" NAME="oldpw" VALUE="$in{'oldpw'}"></P>
<P>Your new password:<BR>
<INPUT TYPE="text" NAME="newpw1"></P>
<P>Type your new password again:<BR>
<INPUT TYPE="text" NAME="newpw2"></P>
<INPUT TYPE="submit" VALUE="Change">
</FORM>
</BODY>
</HTML>
PrintTag
exit(0);  
}
#check for existence of lock file  
if (-e $lokfile)   
{ 
#lock file exists! print message & shut down   
print <<"PrintTag";
<H1>Try again!</H1>  
<P>The database is in use. Please try again later.</P>  
</BODY>  
</HTML>  
PrintTag
exit(0);  
} 
#everything is okay. Create lock file.  
open(LOCK_FILE, ">$lokfile") || 
die "Couldn't create $lokfile\n";
#open password file in read-only mode 
open(FILE,"$pwfile") || 
die "Can't find $pwfile.\n"; 
#store database contents in an array and close file
@indata = <FILE>;
close(FILE);
#open temp file in overwrite mode 
open(TEMP,">$tmpfile") || 
die "Can't create $tmpfile.\n"; 
#copy password file contents to temp file 
#use a foreach loop to process each record in the array
foreach $i (@indata)
{
#remove hard return character from each record
chomp($i);
#split fields on pipe character
#assign a variable name to each of the fields
($username,$password) = split(/\|/,$i);
if ($username eq $in{'oldname'} && 
$password eq $in{'oldpw'} && 
$in{'delete'} ne "yes")
{
print TEMP "$in{'oldname'}|$in{'newpw1'}\n";   
print "<P><h1> Success!</h1>Your password has been changed.</P>\n";
}
elsif ($username eq $in{'oldname'} && 
$in{'delete'} eq "yes")
{
print "<P>Your password has been deleted.</P>\n";
}
else
{
print TEMP "$i\n";
}
} 
#close temp file 
close(TEMP);
#change file names 
rename($pwfile, $pwfile.".old"); 
rename($tmpfile, $pwfile); 
#close and delete lock file 
close(LOCK_FILE); 
unlink($lokfile);
#close web page
print "<P>Thank you! </P>\n";
print "</BODY></HTML>\n";
#end of script

-- 
To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
For additional commands, e-mail: beginners-cgi-help@perl.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About