Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 22nd, 2001, 11:58 AM
JennyW JennyW is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 15 JennyW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old May 22nd, 2001, 03:02 PM
JeffCT JeffCT is offline
PHP & Ruby Developer
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2001
Posts: 1,437 JeffCT User rank is Lance Corporal (50 - 100 Reputation Level)JeffCT User rank is Lance Corporal (50 - 100 Reputation Level)JeffCT User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 5 h 36 m 40 sec
Reputation Power: 9
Re: Perl novice - CGI script trouble

Quote:
Originally posted by JennyW
Hi everyone.

#!c:\perl\bin\bin\perl.exe

# URL to go to if there is a problem with form input
$ErrorPage = "a_fail.html";

This is the address of a web page that the script will automatically forward the user to if there's a problem with what they entered into your form.

# URL to go to when form has been successfully submitted
$ThankPage = "a_thanks.html";

The address of a web page to forward your user to when they successfully submit the email form.

# URL to go to if a 'foreign' referer calls the script
$EvilReferer = "http://www.cnn.com";;

This is the address of a web page to forward the user to if someone on a different web site is trying to access your form mailer script. For example, someone could write an HTML form that submitted to Your script. You don't want them doing this so you could set up something like bad.html and make it say
"Bad referer" or whatever you want.

# Script works only on your server(s) - ('URL1','URL2')
@referers = ('www.yoursite.com','yoursite.com');

These define the web sites that can access your form mailer script. If a site not listed tries to access it, it will send them to the page you defined in the variable above.

# Location of mail program - check your doc or ask admin
$MailProgram = '/usr/lib/sendmail';

I have no idea what to set this to since you're on Windows


Reply With Quote
  #3  
Old May 23rd, 2001, 02:12 PM
Pressly Pressly is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 48 Pressly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Talking Scientific Wild Guess

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.

Reply With Quote
  #4  
Old May 24th, 2001, 08:31 AM
JennyW JennyW is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 15 JennyW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old May 24th, 2001, 08:55 AM
Pressly Pressly is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 48 Pressly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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).

Reply With Quote
  #6  
Old May 24th, 2001, 09:45 AM
JennyW JennyW is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 15 JennyW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #7  
Old May 24th, 2001, 10:06 AM
Pressly Pressly is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 48 Pressly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Post Directory Assistance

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)."

Reply With Quote
  #8  
Old May 24th, 2001, 11:40 AM
JennyW JennyW is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 15 JennyW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy

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

Reply With Quote
  #9  
Old May 25th, 2001, 08:36 AM
Pressly Pressly is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 48 Pressly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Lightbulb Another Clue or Two

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.

Reply With Quote
  #10  
Old May 25th, 2001, 12:14 PM
JennyW JennyW is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 15 JennyW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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:
Add the full script URL to your form:

ACTION="http://members.home.net/pie3.14/cgi-bin/AlphaMail.cgi"

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

Reply With Quote
  #11  
Old May 25th, 2001, 01:28 PM
Pressly Pressly is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 48 Pressly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Question Only Slightly Confused

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).

Reply With Quote
  #12  
Old May 30th, 2001, 02:54 PM
mullaney mullaney is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 0 mullaney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb First Line of Script

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

Reply With Quote
  #13  
Old June 6th, 2001, 01:40 AM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Perl novice - CGI script trouble


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |