Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

getting a cgi script working

by mhorvat42 (Acolyte)
on Jul 29, 2000 at 00:28 UTC ( #25003=perlquestion: print w/replies, xml ) Need Help??
mhorvat42 has asked for the wisdom of the Perl Monks concerning the following question:

i have access to an account (free) on -- they provide me with a cgi-bin directory but no help as on how to get them working on they're server any suggestions

Replies are listed 'Best First'.
RE: getting a cgi script working
by ferrency (Deacon) on Jul 29, 2000 at 00:39 UTC
    First of all, Many Monks will probably tell you that cgi-bin Is Not Perl. Often Perl is used to write scripts that use the Common Gateway Interface (CGI), but that is mere coincidence.

    For us to be of much help, you should probably start by determining whether perl exists on the hypermart web server machine. Do you know what operating system is on there? Do they give you shell access or only ftp access? Your best bet is probably to ask the Hypermart people how to use their cgi-bin.

    If it's an NT-hosted web server, it might not have Perl at all. If it's on a form of UNIX, it probably does. Type which perl to see where perl lives. From there, the basic procedure (this is a very generic answer, but it was a pretty general question...) is to write a perl script which prints out HTTP headers followed by HTML code. In practice there are Many ways to accomplish this, and looking in the Categorized Questions and Answers section about CGI programming will give you a lot of clues.

    If you have a more specific question I'd be glad to attempt a more specific answer.


    Update: Okay, since you stated they give you no help on using cgi-bin, maybe asking them isn't the best way to figure out how to use it...

(Ovid) Re: getting a cgi script working
by Ovid (Cardinal) on Jul 29, 2000 at 01:00 UTC
    After playing around with their site, I see that Perl is supported. They have a support page that has a link you can click on to get more information about CGI scripting with Perl. However, this page requires a username and password (which I assume you have), so I could not read further.

    Read what ferrency said, but (forgive me Father for I have sinned) forget what the Anonymous Monk wrote in points two and three.

    always start out your scripts with a "Content-type: <something>\n\n" line.
    If you include that in your script, it means you are not using the CGI module. Trust me on this, if you need to use to host your site, you shouldn't be trying to do CGI without this module. People are probably going to be using because they're not familiar with setting up their own domain or perhaps can't afford one. Either way, this implies (to me) a lack of experience in this area. CGI is a protocol that is fraught with pitfalls for the unwary. Perl UberGurus get tripped up with cgi problems. You're not going to outthink them (no offense). Learn the CGI module well and you will be richly rewarded (in terms of the frustrations you won't experience from CGI problems).
    If a script runs in a command-line window, then it should also work as a cgi.
    Well, kinda sorta. If you're not using the aforementioned module, you're probably not passing form data to your script from the command line which virtually guarantees that you'll have problems running it from there.


Re: getting a cgi script working
by lolindrath (Scribe) on Jul 29, 2000 at 19:28 UTC
    Hey mhorvat42, is easy to setup.
    first get into the file manager and make a folder and chmod it using their utility at the bottom of the file manager to 777, then ftp in or write your script and put it in that folder and chmod it to 755, then just go in your web browser and type in the URL, it should execute easily.

Re: getting a cgi script working
by Cirollo (Friar) on Jul 29, 2000 at 01:08 UTC
    A little tip: if you have FTP access only, no shell, make sure that you're uploading your scripts in ASCII mode, not binary mode...lots of FTP clients default to binary.

    Also, make sure the script is executable - a 'chmod 755' will do the trick.

    I can remember being screwed up by these waay too many times, back in my wee days. You know something is wrong when a Hello, world script gets you the dreaded "500 Server Error".

Re: getting a cgi script working
by Anonymous Monk on Jul 29, 2000 at 00:45 UTC
    There exist a number of good resources books, and such, that can answer this question much better for you than I can, but here are a couple simple rules to keep in mind.
    1. make sure that the script is executable.
    2. always start out your scripts with a "Content-type: <something>\n\n" line.
    3. If a script runs in a command-line window, then it should also work as a cgi.
Re: getting a cgi script working
by ivory (Pilgrim) on Jul 29, 2000 at 00:54 UTC
    check out a neat online CGI course at It's pretty easy to understand and free :) Plus, the author kindly gives lots of examples and explanations that will probably be very helpful for ya. --Ivory
      ivory: my sincerest apologies for contradicting you, but I would recommend someone NOT use this online course.
      1. Does not explain taint checking until chapter 16 (and then has subtle errors in her regex and her "manpage" lister won't list all manpages). Taint checking also appears to be the extent of her security knowledge.
      2. Her "taint checking" example also has a glaring security hole. If the form value doesn't pass her taint checking, she prints it back out to the browser. That would allow a hacker could allow a hacker to exploit cross-site scripting vulnerabilites with JavaScript and to do redirects to other sites.
      3. She doesn't use the -w switch, strict, or Leaving any of those three off is going to cause the Web developer to waste a lot of time debugging things that they'd catch instantly with those three.
      Ovid problem. I must admit that I neither read the course nor the original post as thuroughly as I should have. Figured a free course might help... :)

        Thanks for pointing out some problems with the course...but the basics are there, right?


        I've just taken a closer look at this course and would like to add another problem to Ovid's list.

        The CGI parameter parsing routine contains the same bug that I have been banging on about on numerous nodes here. In short, it breaks when given a CGI query string that looks like:


        According to the CGI specs, this is completely valid and both values for the key 'key2' need to be accounted for. The code given in the CGI101 course overwrites the first value with the second.

        Looks like this course should be avoided.


        European Perl Conference - Sept 22/24 2000, ICA, London
Re: getting a cgi script working
by mhorvat42 (Acolyte) on Jul 29, 2000 at 11:44 UTC
    thank you i'm headed there now to see if i can find a tutorial on how to cgi on "their" site

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://25003]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2018-06-19 06:02 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.