Click to See Complete Forum and Search --> : New at this, "Permission Denied" after several successful attempts...
britne
09-08-2006, 01:55 PM
Hi, looking for some help here. I'm totally new at this, so please bear with me.
I've been writing a PERL script for my website. Following along with the primer for PERL at HTMLGoodies.com, I made this script step-by-step and tested it along the way, adding a little more each time. It worked at each step of the process, sending an email to me and displaying a thank you page.
Now, just as I've added the last thing I wanted into the script (radio buttons at the end), I get this message:
CGIWrap encountered an error while attempting to execute this script:
Error Message: Permission denied
Error Number: 13
This message usually indicates there is a problem with the script itself. Often this indicates either that the #! line of the script is incorrect, or the script was uploaded in binary mode instead of ascii mode. Check to make sure that the script does not have control-M's at the end of every line. That will prevent it from executing. An easy fix that takes care of this most of the time is to put '#!/.../perl --' instead of '#!/.../perl' on the first line of the script. This is typically a problem if the script was edited or uploaded from a DOS/Windows/Macintosh station to a unix based server.
If you are not the owner of this script, please forward this error and the URL that caused it to the script owner. That is often the component in the URL right after /cgiwrap/.
So, as it said, I changed the #! line to add the 2 dashes (--) after it, and that didn't help.
There are no control-M's, to my knowledge.
I didn't upload the script from anywhere, I used my server's file editor (Fileman) to write the script. All it looks like is a notepad box, it doesn't have anything fancy, except that it's built in, so I don't have to FTP anything. It does, however, have a PERL syntax checker, which I ran, and it said everything was fine.
I don't know what or where /cgiwrap/ is. I have my files in my cgi-bin directory.
http://www.beardesignsonline.com/cgi-bin/custom.html <-- the page where my form is
http://www.beardesignsonline.com/cgi-bin/custom.cgi <-- my cgi script
Any advice is appreciated!!
robertketter
09-08-2006, 04:03 PM
could you please include your script within code brackets so we can get a look at the script itself.
britne
09-09-2006, 12:20 AM
#!/usr/bin/perl --
# That is the path to PERL just above It MUST be first in the script
# The following accepts the data from the form
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("C", hex($1))/eg;
$FORM{$name} = $value;
}
# The following sends the email
open (MESSAGE,"| /usr/lib/sendmail -t");
print MESSAGE "To: $FORM{submitaddress}\n";
print MESSAGE "From: $FORM{email}\n";
print MESSAGE "Subject: Custom Request from $FORM{name}\n\n";
print MESSAGE "Necklace or Choker = $FORM{Necklace_or_Choker}\n";
print MESSAGE "Bracelet or Anklet = $FORM{Bracelet_or_Anklet}\n";
print MESSAGE "Earrings = $FORM{Earrings}\n";
print MESSAGE "Watch = $FORM{Watch}\n";
print MESSAGE "Ring = $FORM{Ring}\n";
print MESSAGE "Accessory = $FORM{Accessory}\n";
print MESSAGE "Similar Item Number = $FORM{Similar_Item}\n";
print MESSAGE "Size = $FORM{Size} ";
if ($FORM{Measurement} eq "Inches")
{print MESSAGE "Inches";}
else
{print MESSAGE "Centimeters";}
if ($FORM{Which_Item} eq "Necklace/Choker")
{print MESSAGE "Necklace/Choker\n";}
elsif ($FORM{Which_Item} eq "Bracelet/Anklet")
{print MESSAGE "Bracelet/Anklet\n";}
elsif ($FORM{Which_Item} eq "Earrings")
{print MESSAGE "Earrings\n";}
elsif ($FORM{Which_Item} eq "Watch")
{print MESSAGE "Watch\n";}
elsif ($FORM{Which_Item} eq "Ring")
{print MESSAGE "Ring\n";}
elsif ($FORM{Which_Item} eq "Accessory")
{print MESSAGE "Accessory\n";}
else
{print MESSAGE "-\n";}
print MESSAGE "Size = $FORM{Size2} ";
if ($FORM{Measurement2} eq "Inches")
{print MESSAGE "Inches";}
else
{print MESSAGE "Centimeters";}
if ($FORM{Which_Item2} eq "Necklace/Choker")
{print MESSAGE "Necklace/Choker\n";}
elsif ($FORM{Which_Item2} eq "Bracelet/Anklet")
{print MESSAGE "Bracelet/Anklet\n";}
elsif ($FORM{Which_Item2} eq "Earrings")
{print MESSAGE "Earrings\n";}
elsif ($FORM{Which_Item2} eq "Watch")
{print MESSAGE "Watch\n";}
elsif ($FORM{Which_Item2} eq "Ring")
{print MESSAGE "Ring\n";}
elsif ($FORM{Which_Item2} eq "Accessory")
{print MESSAGE "Accessory\n";}
else
{print MESSAGE "-\n";}
print MESSAGE "Size = $FORM{Size3} ";
if ($FORM{Measurement3} eq "Inches")
{print MESSAGE "Inches";}
else
{print MESSAGE "Centimeters";}
if ($FORM{Which_Item3} eq "Necklace/Choker")
{print MESSAGE "Necklace/Choker\n";}
elsif ($FORM{Which_Item3} eq "Bracelet/Anklet")
{print MESSAGE "Bracelet/Anklet\n";}
elsif ($FORM{Which_Item3} eq "Earrings")
{print MESSAGE "Earrings\n";}
elsif ($FORM{Which_Item3} eq "Watch")
{print MESSAGE "Watch\n";}
elsif ($FORM{Which_Item3} eq "Ring")
{print MESSAGE "Ring\n";}
elsif ($FORM{Which_Item3} eq "Accessory")
{print MESSAGE "Accessory\n";}
else
{print MESSAGE "-\n";}
print MESSAGE "Size = $FORM{Size4} ";
if ($FORM{Measurement4} eq "Inches")
{print MESSAGE "Inches";}
else
{print MESSAGE "Centimeters";}
if ($FORM{Which_Item4} eq "Necklace/Choker")
{print MESSAGE "Necklace/Choker\n";}
elsif ($FORM{Which_Item4} eq "Bracelet/Anklet")
{print MESSAGE "Bracelet/Anklet\n";}
elsif ($FORM{Which_Item4} eq "Earrings")
{print MESSAGE "Earrings\n";}
elsif ($FORM{Which_Item4} eq "Watch")
{print MESSAGE "Watch\n";}
elsif ($FORM{Which_Item4} eq "Ring")
{print MESSAGE "Ring\n";}
elsif ($FORM{Which_Item4} eq "Accessory")
{print MESSAGE "Accessory\n";}
else
{print MESSAGE "-\n";}
print MESSAGE "Specific information:\n";
print MESSAGE "$FORM{Details}\n\n";
print MESSAGE "$FORM{Price_Range}\n";
if ($FORM{Rush} eq "yes")
{print MESSAGE "RUSH ITEM!\n\n"; }
elsif ($FORM{Rush} eq "no")
{print MESSAGE "Not a rush item.\n\n"; }
else
{print MESSAGE "Rush question not answered, please clarify with customer.\n\n"; }
close (MESSAGE);
&thank_you;
}
#The following creates the Thank You page display
sub thank_you {
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Thank You!</TITLE>\n";
print "</HEAD>\n";
print "<BODY BGCOLOR=#cccc99 TEXT=#000000>\n";
print "<H3><font face=verdana>Thank You!</font></H3>\n";
print "\n";
print "<p><font face=verdana size=2>Thank you for submitting a custom design request. We will review your order shortly and contact you with the approximate cost and shipping date.</font>\n";
print "</p>\n";
print "<p><font face=verdana size=2>If you have submitted a request in error, or would like to cancel your request, please send an e-mail (using the name and e-mail address you entered on the form, so that we can match your request!) to our order department with the subject 'Cancel Custom Order'</font>.\n";
print "</p>\n";
print "<font face=verdana size=2><a style=color:000000 href=http://www.beardesignsonline.com/bearmain.html>Click here to return to the homepage.</a></font>\n";
print "</BODY>\n";
print "</HTML>\n";
exit(0);
}
robertketter
09-09-2006, 09:39 AM
Removed... Old Content
britne
09-09-2006, 10:39 AM
In your script, you have the send email and print html sections twice. For the sake of learning, why is that?
Also, if I copy and paste your script into a new file and direct it to post there, it doesn't work.
However, it does work if I tell it to post at the address you gave me.
britne
09-09-2006, 02:41 PM
... since I can't get the script to work, I can't test this myself.
If I want to send 2 emails at once, one to myself giving me the details of the form, and the other to the person who filled out the form, confirming their submission. Can I do this just by repeating the open MESSAGE command? Should I change MESSAGE to something else? Do I need to make a subroutine like the thank you page?
Sorry for the amateur questions, I'm just trying to learn.
britne
09-09-2006, 03:03 PM
The initial problems was that my permissions were set wrong. Doh!
I then answered my own second question, it works by just using the same open and close message command.
Here's the whole thing, so hopefully other people could learn from it too!
#!/usr/bin/perl
# ADDED TO HELP DEBUG SCRIPT
use CGI::Carp qw(fatalsToBrowser);
# That is the path to PERL just above It MUST be first in the script
# The following accepts the data from the form
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("C", hex($1))/eg;
$FORM{$name} = $value;
}
# The following sends the email
open (MESSAGE,"|/usr/lib/sendmail -t");
print MESSAGE "To: $FORM{email}\n";
print MESSAGE "From: $FORM{submitaddress}\n";
print MESSAGE "Subject: Thank you for submitting a design request!\n\n";
print MESSAGE "Thank you for submitting a design request at http://www.beardesignsonline.com.\n";
print MESSAGE "We will be reviewing your order shortly and contacting you with some initial information.\n\n";
print MESSAGE "If you believe you have received this message in error, please reply to this message and let us know.\n\n";
print MESSAGE "Thank you,\n";
print MESSAGE "Bear Designs Order Team\n";
close (MESSAGE);
open (MESSAGE,"| /usr/lib/sendmail -t");
print MESSAGE "To: $FORM{submitaddress}\n";
print MESSAGE "From: $FORM{email}\n";
print MESSAGE "Subject: Custom Request from $FORM{name}\n\n";
print MESSAGE "Necklace or Choker = $FORM{Necklace_or_Choker}\n";
print MESSAGE "Bracelet or Anklet = $FORM{Bracelet_or_Anklet}\n";
print MESSAGE "Earrings = $FORM{Earrings}\n";
print MESSAGE "Watch = $FORM{Watch}\n";
print MESSAGE "Ring = $FORM{Ring}\n";
print MESSAGE "Accessory = $FORM{Accessory}\n";
print MESSAGE "Similar Item Number = $FORM{Similar_Item}\n";
print MESSAGE "Size = $FORM{Size} ";
if ($FORM{Measurement} eq "Inches")
{print MESSAGE "Inches";}
else
{print MESSAGE "Centimeters";}
if ($FORM{Which_Item} eq "Necklace/Choker")
{print MESSAGE "Necklace/Choker\n";}
elsif ($FORM{Which_Item} eq "Bracelet/Anklet")
{print MESSAGE "Bracelet/Anklet\n";}
elsif ($FORM{Which_Item} eq "Earrings")
{print MESSAGE "Earrings\n";}
elsif ($FORM{Which_Item} eq "Watch")
{print MESSAGE "Watch\n";}
elsif ($FORM{Which_Item} eq "Ring")
{print MESSAGE "Ring\n";}
elsif ($FORM{Which_Item} eq "Accessory")
{print MESSAGE "Accessory\n";}
else
{print MESSAGE "-\n";}
print MESSAGE "Size = $FORM{Size2} ";
if ($FORM{Measurement2} eq "Inches")
{print MESSAGE "Inches";}
else
{print MESSAGE "Centimeters";}
if ($FORM{Which_Item2} eq "Necklace/Choker")
{print MESSAGE "Necklace/Choker\n";}
elsif ($FORM{Which_Item2} eq "Bracelet/Anklet")
{print MESSAGE "Bracelet/Anklet\n";}
elsif ($FORM{Which_Item2} eq "Earrings")
{print MESSAGE "Earrings\n";}
elsif ($FORM{Which_Item2} eq "Watch")
{print MESSAGE "Watch\n";}
elsif ($FORM{Which_Item2} eq "Ring")
{print MESSAGE "Ring\n";}
elsif ($FORM{Which_Item2} eq "Accessory")
{print MESSAGE "Accessory\n";}
else
{print MESSAGE "-\n";}
print MESSAGE "Size = $FORM{Size3} ";
if ($FORM{Measurement3} eq "Inches")
{print MESSAGE "Inches";}
else
{print MESSAGE "Centimeters";}
if ($FORM{Which_Item3} eq "Necklace/Choker")
{print MESSAGE "Necklace/Choker\n";}
elsif ($FORM{Which_Item3} eq "Bracelet/Anklet")
{print MESSAGE "Bracelet/Anklet\n";}
elsif ($FORM{Which_Item3} eq "Earrings")
{print MESSAGE "Earrings\n";}
elsif ($FORM{Which_Item3} eq "Watch")
{print MESSAGE "Watch\n";}
elsif ($FORM{Which_Item3} eq "Ring")
{print MESSAGE "Ring\n";}
elsif ($FORM{Which_Item3} eq "Accessory")
{print MESSAGE "Accessory\n";}
else
{print MESSAGE "-\n";}
print MESSAGE "Size = $FORM{Size4} ";
if ($FORM{Measurement4} eq "Inches")
{print MESSAGE "Inches";}
else
{print MESSAGE "Centimeters";}
if ($FORM{Which_Item4} eq "Necklace/Choker")
{print MESSAGE "Necklace/Choker\n";}
elsif ($FORM{Which_Item4} eq "Bracelet/Anklet")
{print MESSAGE "Bracelet/Anklet\n";}
elsif ($FORM{Which_Item4} eq "Earrings")
{print MESSAGE "Earrings\n";}
elsif ($FORM{Which_Item4} eq "Watch")
{print MESSAGE "Watch\n";}
elsif ($FORM{Which_Item4} eq "Ring")
{print MESSAGE "Ring\n";}
elsif ($FORM{Which_Item4} eq "Accessory")
{print MESSAGE "Accessory\n";}
else
{print MESSAGE "-\n";}
print MESSAGE "Specific information:\n";
print MESSAGE "$FORM{Details}\n\n";
print MESSAGE "$FORM{Price_Range}\n";
if ($FORM{Rush} eq "yes")
{print MESSAGE "RUSH ITEM!\n\n";}
elsif ($FORM{Rush} eq "no")
{print MESSAGE "Not a rush item.\n\n";}
else
{print MESSAGE "Rush question not answered, please clarify with customer.\n\n";}
close (MESSAGE);
&thank_you;
}
#The following creates the Thank You page display
sub thank_you {
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Thank You!</TITLE>\n";
print "</HEAD>\n";
print "<BODY BGCOLOR=#cccc99 TEXT=#000000>\n";
# ADDED TO HELP DEBUG SCRIPT
# print "<p>DEBUG: An email was sent to $FORM{submitaddress}.</p>\n";
print "<H3><font face=verdana>Thank You!</font></H3>\n";
print "\n";
print "<p><font face=verdana size=2>Thank you for submitting a custom design request. We will review your order shortly and contact you with the approximate cost and shipping date.</font>\n";
print "</p>\n";
print "<p><font face=verdana size=2>If you have submitted a request in error, or would like to cancel your request, please send an e-mail (using the name and e-mail address you entered on the form, so that we can match your request!) to our order department with the subject 'Cancel Custom Order'</font>.\n";
print "</p>\n";
print "<font face=verdana size=2><a style=color:000000 href=http://www.beardesignsonline.com/bearmain.html>Click here to return to the homepage.</a></font>\n";
print "</BODY>\n";
print "</HTML>\n";
exit(0);
}
Thank you for your help!
robertketter
09-09-2006, 04:53 PM
I am a bit confused... You removed the 'else' statement from the script I added. Your first line is an 'if' statement, but if it fails you have no 'else' statement or script exit. If you access the script directly without using the form the 'if' will be false and the script will report an error and end without exit. You have to assume the script will be accessed directly and that it will run and exit so as not to hang on the server. The changes I made adding the else statement was just to show you how the script would work if the 'if' returned false. Another thing to note is opening the message 2 times to send the email to 2 people is not a good use of resources... all you have to do is add the second email address seperated by a comma to the To: line. Anyways I hope this helps you. Robert Ketter, www.RobertKetter.com :)