• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

CGI not working...

agnieszka

New Member
i've ftp'd my cgi file that keeps giving me "500" errors as a txt file

http://agspage.filetap.com/cgi-bin/form.txt

can someone take a look and maybe tell me what's wrong with it, or make improvement suggestions?

i'm not a programmer in the slightest, i modified this script from another (rather heavily) and now it doesn't work (it didn't before either). so if you find what's wrong, tell me in plain english what to do to fix it because i won't understand your techno-dribble otherwise.

thanks in advance.

ag.
 
Honestly, if you are going to modify a script -- you should learn the programming language in question...

I can spot quite a few problems. For one, when you are inside "quotes" (such as your 'print' statements), you must precede any literal quotes with a backslash.

In other words:

print "This is a "quoted" word";

Will not work. Perl doesn't know the quotes around "quoted" are to be printed literally, so you must do this:

print "This is a \"quoted\" word";

That is one of many, many ways around this problem (Perl is a great language because there is no right or wrong way to accomplish anything).

I won't go any further debugging the code, however; you will need to learn Perl or contract someone (or recruit a guru friend) to help you...

<EDIT>
I just realized you're the one asking about escaping in another thread, so I'll give you this quick advice: go through your script line by line, and you will find the bare quotes I mentioned. I am not saying that's the only problem necessarily, as I have not gone through the whole thing.

One more bit of advice: Perl is your friend and, in most cases, will tell you exactly what is wrong with the script.

Run your script with the -c flag, like this:

perl -c filename.pl

The -c flag has Perl check the syntax of your script.

Quick notes:
- The way you are handling output is not the best way. Like I said, there is no wrong way, but there are ways to avoid. In this case, printing each line one print statement at a time is very time consuming and (obviously) error-prone.

- Instead of adding two emails to the From: header as you are attempting to do, use a BCC: or CC: header for the secondary destination.

- You are assuming the open() call succeeded. You should always check for success, rather than assuming it will just always work.

Again, learn the language or hire a programmer is my advice.

PS -- what's wrong with using something like Matt Wright's FormMail, instead of modifying this script?
</EDIT>
 
Last edited:
hey i don't get it. why is everyone telling me to "just learn perl". whenever someone else asks a cgi question people actually help them out and past a little code or give a little info. what's different about my questions (i had another post as well, recently) that prompts people to say "just learn perl".

to "just learn perl" is not an easy thing for me. it's like learning japanese or something. it'll take years to be compitent in a language, and that includes programming ones. people study these languages at uni over several years, and you guys want me to learn it over some stupid meta characters??

i already have enuf on my plate with the uni i'm doing already, i don't have the time to "just learn perl".

i thought this forum was to help people out.

btw...

Run your script with the -c flag, like this:
perl -c filename.pl

huh? where? in dos? i used notepad to edit this script, i know for sure notepad has no such feature as running scripts.
 
Originally posted by agnieszka
hey i don't get it. why is everyone telling me to "just learn perl". whenever someone else asks a cgi question people actually help them out and past a little code or give a little info. what's different about my questions (i had another post as well, recently) that prompts people to say "just learn perl".
isn't it obvious? everyone else is against you.

sheesh, don't take everything so personally.
 
Originally posted by agnieszka

to "just learn perl" is not an easy thing for me. it's like learning japanese or something. it'll take years to be compitent in a language, and that includes programming ones. people study these languages at uni over several years, and you guys want me to learn it over some stupid meta characters??

japanese isn't hard to learn

if u studied jap or perl for 1 week straight you should be able to know something
 
I'm not saying noone is willing to help you; the suggestions I gave should help you to debug your script. I made some other comments which I'll explain in a minute, but I did offer you as much help as I would offer anyone.

My point was simply that if you're going to take up Perl scripting, it's best to learn the language. It's not as difficult as you might imagine. Programming languages are much more human than they are computer -- because they are designed by humans for humans. Perl is an especially good example (though admittedly it's probably not the best language to learn first).

To expand on your analogy, you wouldn't take a job translating a web page into Japanese, would you? Likely no, unless you were willing to learn the language first. Or you might pay someone else to do it (hence my other suggestion).

I have no problem helping people with their programming. I also like to think I have quite a bit of patience in matters like these. However, it does become difficult sometimes to help someone who has no idea what I'm talking about. It's not that I'm impatient, not at all (if I were, I just wouldn't post at all). But if you were to learn the language a little bit, you'd understand comments like "perl -c filename.pl".

It doesn't take years to grasp the basic concepts of programming (in any language). It may take years to become an expert, but to learn the basic syntax of a particular language and, at the same time, learn basic programming concepts which apply to any language (such as meta-characters and quoting), it only takes a bit of dedication. A few weeks and you'll be modifying scripts left and right without much thought.

If you don't have that kind of time, dedication, or motivation, then again I have to recommend hiring someone to help you (or, as I mentioned earlier, finding another ready-made script that already does what you want).

Also keep in mind that, by blindly plugging in bits of code people tell you to use until it finally works, you aren't actually understanding the code. Understanding your code is important, especially on a world-accessible script. Code you don't understand will never be very secure, and this is especially important these days.

As Keith says, this is nothing personal against you or anyone else, and I'm sorry if it sounded that way. I know learning Perl isn't easy, but sometimes you need to face reality. In this case, you must either learn Perl or be stuck in situations such as this... There's not much I can say to get around this other than writing your script for you, which I personally am not willing to do.

---

With that out of the way, I'll take a moment and explain "perl -c filename.pl".

You will need to log in to your server via Telnet or SSH. You then need to locate your script -- change to the directory the script is located in. I can't tell you where this is, as it depends on where you placed it, and how your server is configured.

Once you are there, you would type:

perl -c filename.pl

Where filename.pl is the name of the script (it might be something.cgi, doesn't matter).

This runs "perl", the interpretor, in a special mode that simply verifies your syntax. If perl doesn't understand something you wrote, it will tell you.

I can't get any more basic than this without teaching you Perl and Unix unfortunatley. I'm not trying to sound condescending, and I am sorry if it sounds this way, but if you're not willing or able to learn these things, I can't recommend trying to modify Perl scripts on your own.
 
ok, don't worry. i've got a working mailform now. i found a ---beautifully--- simple script that does exactly what i want - sends me the email and sends back a "thanks" to the user seconds after they click "submit".

thanks for trying to help. btw, i understood the telnet thingy. also, perl may be easy for you, and it may be easy for others, but remember, quantum physics is also easy for some people. i'm just not one of them. i'm not a programmer, like i said in the first post - i have no programming background, no programming training, not one programming language under my belt - i can't even figure out javascript on my own... it's only a simple personal web page... i just wanted to be happy...

___________________________________
http://agspage.filetap.com
 
Back
Top