|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Perl novice - CGI script trouble
Hi everyone.
I’m trying to test a .cgi script, but I’m having a ‘lil trouble. First I’ll give you some info. I have Apache 1.3.19 running off a console on a Windows 98 machine. I also have Perl 5.004_02 The .cgi script I’m trying to test allows website visitors to easily email me from an <html> Form. I highlighted the segments I think I’m making errors on. Below is only part of the script. To see the whole script go to this link… http://members.home.net/pie3.14/AlphaMail.txt #!c:\perl\bin\bin\perl.exe # URL to go to if there is a problem with form input $ErrorPage = "a_fail.html"; # URL to go to when form has been successfully submitted $ThankPage = "a_thanks.html"; # URL to go to if a 'foreign' referer calls the script $EvilReferer = "http://www.cnn.com";; # E-mail address to send intake form to (your address) # If not using PERL 5, escape the @ thus: \@ instead of @ $YourEmail = 'themustache@hotmail.com'; # Script works only on your server(s) - ('URL1','URL2') @referers = ('www.yoursite.com','yoursite.com'); # Location of mail program - check your doc or ask admin $MailProgram = '/usr/lib/sendmail'; # Subject of the e-mail autoreply to the submitter $Subject = "Thanks for Your Message!"; # Header line in the auto-reply message $Header = "GOOBERS UNLIMITED"; # Brief tail message for body of e-mail autoreply $TailMessage = "If your message requires a reply, we'll get back to you soon."; # Your signature lines the end of the autoreply e-mail $Signature1 = "John Q. Public"; $Signature2 = "www.YourSite.com";; [/font] I’m unsure what to enter in the highlighted segments? Is this where I’m making errors? Thanks, Jenny |
|
#2
|
|||
|
|||
|
Re: Perl novice - CGI script trouble
Quote:
|
|
#3
|
|||
|
|||
|
Re:
$MailProgram = '/usr/lib/sendmail'; Since your shebang line uses a DOS (backslashed) path, this probably should be '\usr\lib\sendmail'. Hang in there. The real fun begins when you get to writing this stuff from scratch. ![]() |
|
#4
|
|||
|
|||
|
Hi guys,
Thanks JeffCT that response was great! Thanks Pressly! I’m uploading my site to a free webhost that has .cgi. Here are my quetsions… 1. I uploaded my a Form to… http://jennyw.netfirms.com/ I used .cgi code (link) below… http://members.home.net/pie3.14/AlphaMail.txt I ONLY adjusted the settable variables, the shebang line and the line under it. Line under shebang line use CGI::Carp qw(fatalsToBrowser); I can’t get my Form to work. I always receive this error… Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, Your Webmaster and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. I know I have the location of perl and sendmail correct. I’ve also set my .cgi file permissions to 755. 2. Am I suppose to do anything with either of the following? CGI Url http://domain.netfirms.com/cgi-bin/file.cgi Your full or absolute root path is: $ENV{'DOCUMENT_ROOT'} Remember to use double quotes around the path. The full path to your www directory would be: "$ENV{'DOCUMENT_ROOT'}/www" The full path to your cgi-bin directory would be: "$ENV{'DOCUMENT_ROOT'}/cgi-bin" Should I be looking at this file for anything… http://jennyw.netfirms.com/cgi/printenv 3. My .cgi file used to be a .pl file, but I just saved it as a .cgi document? Is that ok? Some similar questions… Using netfirms.com (my free host) 4. If I have html documents that call on .cgi docs then what folder do I put my pages in? Do I put them all in the same folder? Or do html docs go in the /www folder and .cgi docs in the /cgi-bin ? 5. I write my files like this… # URL to go to if there is a problem with form input $ErrorPage = "a_fail.html"; But some of the files have a slash (/) in front of the file name, so should I have a slash before the file name? $ErrorPage = "/a_fail.html"; Thanks so much, Jenny |
|
#5
|
|||
|
|||
|
One Small Step
In your HTML form, add a forward slash before "cgi-bin/alphamail.cgi" so that you have:
ACTION="/cgi-bin/alphamail.cgi" This is assuming your alphamail.cgi file is loaded on the same server. Otherwise you would need to include the whole URL (http://www.somehost.com/cgi-bin/alphamail.cgi). |
|
#6
|
|||
|
|||
|
Hi,
Yes, my alphamail.cgi file is on the same server as my Form. My alphamail.cgi file is not in the www folder, but it’s in the .cgi-bin folder. Why does there have to be a forward slash (/) before, cgi-bin/alphamail.cgi If anyone has the chance can you please take a look at the questions in my post before this one? Thanks, Jenny |
|
#7
|
|||
|
|||
|
Directories are set up in a hierarchy, with slash marks (or backslashes in DOS/Windows) setting off the chain of subdirectories. The topmost directory is Root, designated by / (or \, as in C:\).
Adding the slash before cgi-bin (/cgi-bin/script.cgi) says, "Start from Root and go to the cgi-bin subdirectory and execute script.cgi." ![]() Without the slash, it says, "Start from the subdirectory you're in (www, for example) and go to subdirectory cgi-bin (which doesn't really exist) and execute script.cgi (which isn't there)." ![]() |
|
#8
|
|||
|
|||
|
Ahhh ha! You explained that so well!
I understand fully! Ok, I added a / to the beginning of my directory, but my script still isn’t working. Errrr. Gonna have to keep playing with it. Thanks, Jenny |
|
#9
|
|||
|
|||
|
I see that your form at http://jennyw.netfirms.com/ is looking for "cgi-bin/alphamail.cgi", but your script is saved as "http://members.home.net/pie3.14/AlphaMail.txt". To make this connect, you need to do at least two things:
1) Save a copy of your script with a ".cgi" suffix in the cgi-bin directory on your free host (be sure to set the permissions): http://members.home.net/pie3.14/cgi-bin/AlphaMail.cgi 2) Add the full script URL to your form: ACTION="http://members.home.net/pie3.14/cgi-bin/AlphaMail.cgi" That should get you a step closer. |
|
#10
|
|||
|
|||
|
Hi Pressly (and others)!
My script is like this… http://members.home.net/pie3.14/AlphaMail.txt ...because I just wanted to show you the actual .cgi code. The script is actually in my .cgi-bin with a .cgi suffix. It looks like the following… alphamail.cgi I understand you when you wrote… Quote:
I know that would work, but I have another question. To repeat, my file is called alphamail.cgi and is in my hosts cgi-bin. Now my html Form has the following paramaters… <FORM NAME="Myform" ACTION="cgi-bin/alphamail.cgi" METHOD="POST"> Going back to previous posts…Should I insert a slash / in front of cgi-bin like this… <FORM NAME="Myform" ACTION="cgi-bin/alphamail.cgi" METHOD="POST"> Thanks so much! Friday! Jenny |
|
#11
|
|||
|
|||
|
Oops!
I looked back through your posts and got it straight (I hope). As long as your form and script are on the same host,<FORM NAME="Myform" ACTION="/cgi-bin/alphamail.cgi" METHOD="POST"> should work (with the / in front of cgi-bin). |
|
#12
|
|||
|
|||
|
You should change your first line to...
#!/usr/bin/perl ...which is the location of your perl interpreter. I checked your webhost provider and found the following reference: (URL) Perl 5 Location #!/usr/bin/perl By the way, don't forget to change the direction of the slashes for /usr/bin/sendmail if you have it backslashed. The system your being hosted on is some sort of UNIX and uses forward slashes. Hope this helps. Bob |
|
#13
|
|||
|
|||
|
perl windows to linux 101
Dear Jenny,
It happens that when you save a text file in windows and upload it to a linux server the " end of line " characters clash and the perfectly good file will give errors. I got caught with this error recently as I forgot the difference using a SSL connection to a web server, where as many of the other connections where regular ftp. Even with say wsftp as the software, make sure you are transfering perl files as ASCII and not BINARY mode After upload try if you have telnet access : perl -c filename.cgi or if no telnet try a simple test with : #!usr/bin/perl use CGI qw(:standard); $wordz = param("help"); print "Content-type: text/plain\n\n"; print "$wordz\n"; Save this file in windows, upload as " me.cgi ", chmod 755, point your browser to this file as in : http://www.yoursite/cgi-bin/me.cgi?help=YES%20it%20WORKS You might see back only " YES it WORKS " in your browser, no html Write if this doesn't help or for more suggestions
__________________
Thanks Foot in Mouth ver 1.2.5 Onion |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Perl novice - CGI script trouble |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|