Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: where to place the .pl fro cgi script

by jonnyfolk (Vicar)
on Oct 25, 2006 at 09:24 UTC ( #580518=note: print w/ replies, xml ) Need Help??


in reply to where to place the .pl fro cgi script

The answers previously given are quite correct, of course, but the precise answer to your question is that hello.pl must be placed in the directory cgi-bin.

Typically this will be found in the public_html directory, but is sometimes not so you may have to look around for it

You also may need to change the permissions on the file to 755 (normally this can be done using you ftp client) and if you are viewing from a browser an html header print "Content-type: text/html\n\n"; before your print 'hello world'; statement will probably be necessary.

Should the script not function after all this come back to us and we'll try to be of more help.


Comment on Re: where to place the .pl fro cgi script
Select or Download Code
Re^2: where to place the .pl for cgi script
by davorg (Chancellor) on Oct 25, 2006 at 09:33 UTC
    but the precise answer to your question is that hello.pl must be placed in the directory cgi-bin

    Er... no. The precise answer is that hello.pl must be placed in whatever directory the configuration of the web server has mapped to the URL /cgi-bin/. This is often a directory called cgi-bin but without examining the web server configuration files you can't be 100% sure. It's possible that it's not mapped onto any directory at all.

    Typically this will be found in the public_html directory

    Well, only on servers that have user directories enabled. And even then only on ones that allow individual users to have cgi-bin directories. That's pretty rare in my experience.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      davorg, you have to get out more. If you go to any of the millions of web hosting sites on the internet you will have trouble finding one that doesn't provide a cgi-bin.

      I had the feeling the the OP was looking for a pointer and if my reply helped then that's good and if not tant pis!

        Having spent five years supporting a set of CGI programs that non-programmers try to install on a wide range of web hosting packages, I'm well aware of how common the standard configuration is. I'm also aware of a significant proportion of web hosting companies who seem to delight in giving customers the weirdest configurations possible.

        Far too often I've confused someone by giving them the standard answer which didn't apply in their circumstances, so I've learnt that the only reasonable answer to give is "you need to ask the person who configured your web server". Your experience obviously differs from mine.

        --
        <http://dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg

Re^2: where to place the .pl fro cgi script
by dorward (Curate) on Oct 25, 2006 at 09:40 UTC

    the precise answer to your question is that hello.pl must be placed in the directory cgi-bin.

    No, that's a common configuration, but not universal, on my system this is called "cgi" not "cgi-bin". The precise answer is the one you get after reading the documentation for your webserver.

    Typically this will be found in the public_html directory, but is sometimes not so you may have to look around for it

    On my system 'public_html' is 'pages', and 'cgi' is a sibling, not a child. You shouldn't have to "look around for it" though, the aforementioned documentation should tell you.

    You also may need to change the permissions on the file to 755

    Hopefully the system will be set up so that world doesn't need access and you can limit execute permission to the group.

    (normally this can be done using you ftp client)

    Although hopefully you are using sftp, rsync over ssh, or some other means of transfering files that doesn't result in passwords being sent in clear text.

    and if you are viewing from a browser an html header print "Content-type: text/html\n\n"; before your print 'hello world'; statement will probably be necessary.

    Would it qualify as a CGI script if it didn't output a Content-type header?

    Either way, printing out the content-type directly instead of using a module (such as CGI.pm) probably isn't the way to go.

Re^2: where to place the .pl fro cgi script
by jhourcle (Prior) on Oct 25, 2006 at 12:02 UTC

    I've managed/supported quite a few servers over the years (dating back to Netscape Server 2, and AOL's NaviServer), and for this sort of question, it's best not to assume anything about their server configuration.

    The system may have all items ending in '.cgi' mapped to mod_cgi in apache, which allows them to place the file anywhere that the webserver can see it, provided it has the correct extension and permissions.

    If they're using CGIwrap (which I suggest for multi-user systems with cgi access), then the cgi-bin directory should not be in public_html, as it may allow folks to read your scripts if you don't have the permissions set correctly. (and in this case, set correctly is not 0755, it's 0500).

    I would assume that whatever server is either using virtual hosts, or is not multi-use, based on the URL that was given, but know that there are many, many different configurations for such things, and so not to guess the directories. (eg, MacOS X places CGIs in /Library/Webserver/CGI-Executables, even though it maps to http://host/cgi-bin/

    ...

    So, my suggestion would be -- if you're using an ISP or hosting service -- contact them. They're the only ones who would know the configuration of their system. If you're hosting your own system, we'll need more information -- is it a default install? If so, what OS?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://580518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-09-01 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (17 votes), past polls