Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running cgi's on windows...can't figure out!

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
i got it able to accept just ".cgi" as an extension.


question: (hope you dno't mind)




i set up a folder called "perl_scripts" on my desktop. i have a file called input.html that looks like this...

*******

--- input.html



<html><head></head>

<body bgcolor=&quot;#ffffff&quot; link=&quot;#808080&quot;>

<p align=&quot;center&quot;> </p><div align=&quot;left&quot;>

<form action=&quot;cgi-bin/readInput.cgi&quot; method=&quot;POST&quot;>

<blockquote>

<table border=&quot;0&quot;>

<tr>
<td align=&quot;right&quot;><em>Name</td></td>
<td><input type=&quot;text&quot; size=35&quot; name=&quot;Contact_FullName&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>Title</em></td>
<td><input type=&quot;text&quot; size=&quot;35&quot; name=&quot;Contact_Organization&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>Street Address</em></td>
<td><input type=&quot;text&quot; size=&quot;35&quot; name=&quot;Contact_StreetAddress&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>City</em></td>
<td><input type=&quot;text&quot; size=&quot;35&quot; name=&quot;Contact_City&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>State/Province</td></td>
<td><input type=&quot;text&quot; size=35&quot; name=&quot;Contact_State&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>Zip/Postal Code</em></td>
<td><input type=&quot;text&quot; size=&quot;12&quot; maxlength=&quot;12&quot; name=&quot;Contact_ZipCode&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>Country</em></td>
<td><input type=&quot;text&quot; size=&quot;25&quot; maxlength=&quot;25&quot; name=&quot;Contact_Country&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>Work Phone</em></td>
<td><input type=&quot;text&quot; size=&quot;25&quot; maxlength=&quot;25&quot; name=&quot;Contact_WorkPhone&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>Home Phone</em></td>
<td><input type=&quot;text&quot; size=&quot;25&quot; maxlength=&quot;25&quot; name=&quot;Contact_HomePhone&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>FAX</em></td>
<td><input type=&quot;text&quot; size=&quot;25&quot; maxlength=&quot;25&quot; name=&quot;Contact_FAX&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>E-mail</em></td>
<td><input type=&quot;text&quot; size=&quot;25&quot; maxlength=&quot;25&quot; name=&quot;Contact_Email&quot;></td>
</tr>

<tr>
<td align=&quot;right&quot;><em>URL</em></td>
<td><input type=&quot;text&quot; size=&quot;25&quot; maxlength=&quot;25&quot; name=&quot;Contact_URL&quot;></td>
</tr>

</table>

</blockquote>
<p>What are your requirements? Include dates, # of people, special needs, etc.</p>
<blockquote>
<p><textarea name=&quot;comments&quot; rows=&quot;5&quot; col=&quot;35&quot;>
</textarea>
</p>
</blockquote>
<p>Please <input type=&quot;submit&quot; value=&quot;submit this form&quot;> when finished or <input type=&quot;reset&quot; value=&quot;clear it&quot;> to start over.</p>
</form>
</body>
</html>


*******


inside the folder i set up a sub folder called 'cgi-bin' in which i put the following script...


*******

--- readInput.cgi



#!/usr/bin/perl

%postInputs = readPostInput();
$dateCommand = &quot;date&quot;;
open (MAIL, &quot;|/usr/sbin/sendmail -t&quot;) || return 0;

select (MAIL);
print << &quot;EOF&quot;;
To: g\@one-degree.com
From: $postInputs{'Contact_Email'}
Subject: $postInputs{'Organization'} Information Requested
$time
$postInputs{'Organization'} Information Requested
Name: $postInputs{'Contact_FullName'}
Email: $postInputs{'Contact_Email'}
Street Address: $postInputs{'Contact_StreetAddress'}
Street Address (cont.): $postInputs{'Contact_Address2'}
City: $postInputs{'Contact_City'}
State: $postInputs{'Contact_State'}
Zip: $postInputs{'Contact_ZipCode'}
Work Phone: $postInputs{'Contact_WorkPhone'}
Home Phone: $postInputs{'Contact_HomePhone'}
FAX: $postInputs{'Contact_FAX'}
Email: $postInputs{'Contact_Email'}
Comments: $postInputs{'comments'}


EOF
close(MAIL);
select(STDOUT);
printThankYou();

sub readPostInput(){

my (%searchField, $buffer, $pair, @pairs);
if ($ENV{'REQUEST_METHOD'} eq 'POST'){
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'} );
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$name = =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$searchField{ $name} = $value;

}
}

return (%searchField);

}

sub printThankYou(){

print << &quot;EOF&quot;;

Content-Type: text/html

<head>
<title>THANK YOU FOR YOUR REQUEST</title>
</head>
<body>
<table cellspacing=2 cellpadding=2 border=0 width=600>
<tr><th><br>
<center>
<font size=+3><b>Thank You $postInputs{'Contact_FullName'}</b></font>
</center><br><br>

<center><b><font size=+1><p>For submitting your information. We will get back to you shortly.</p>
</b>
</font>
<center>
</th></table>
</body>
</html>

EOF
}


*********



i have no idea of this, just wrote it out of the book and would like to decipher...best way i learn! but the problem, it doesn't do anything. now, i have the same set up on my server live on the web, and at least there, i get an error message that reads...

syntax error at readInput.cgi line 43, near &quot;= =~&quot;
Execution of readInput.cgi aborted due to compilation errors.



can you trouble shoot? i installed perl win32 and set all the defaults. is the #!/usr... in the beginning pointing to perl on my system? perl is at c:/windows/perl according to my file tree...

- g
 
Well, perhaps the book you're looking at has a typo.

The line $name = =~ tr/+/ /;

should be: $name =~ tr/+/ /;

Good luck,

brendanc@icehouse.net
 
ok, i just checked my email, and to my surprise, there are the forms i set up...so that part of the script is good...the problem must lie in the thankyou(), right?

-g


thanks for the &quot;==&quot; prob....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top