Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Perl script shows source code

by chrrutgers (Initiate)
on Oct 27, 2007 at 13:55 UTC ( [id://647574]=perlquestion: print w/replies, xml ) Need Help??

chrrutgers has asked for the wisdom of the Perl Monks concerning the following question:

Dear all,
I have been working for a while now to get perl working outside my cgi-bin folder. My server is now configured right according to my hoster but when I try to execute my login script I get the soerce code instead of the login screen.

I am working on a Centos 4 Server with mod_perl disabled because according to the script makers the program doesn't support mod_perl.

Is there any one who can help me? I am a newbie to perl.

Replies are listed 'Best First'.
Re: Perl script shows source code
by Joost (Canon) on Oct 27, 2007 at 14:56 UTC
    Do you get the HTML source or the source of the script itself?

    If you get the HTML source, you must make sure you send the right content-type header. If you see the perl source code, probably either the script's file extension is wrong (or at least, your webserver doesn't recognize it as a cgi script) or your webserver does not have execute rights to the script.

    Take a look at the server's error log.

Re: Perl script shows source code
by graff (Chancellor) on Oct 27, 2007 at 15:14 UTC
    Your question is not very clear. When the hoster says the server is "configured right", what are the particular features of the configuration that should be relevant to your task? (For example, does the config involve allowing scripts to be executed from directories other than "cgi-bin", and/or does it involve scripts to be executed if their file names end with a particular extension such as ".cgi" or ".pl"?)

    If the web server config is "right" in terms of allowing your script file (in its current location, with its current file_name.extension) to be treated as an executable script -- and if this web server is a unix or linux OS -- you still need to check a couple things about the script file:

    • Are the permissions on the file set so that it is executable? (See the "chmod" shell command, which is similar to the perl chmod function.)

    • Does the first line of the script file (the "shebang" line) correctly identify the path to perl (and does the file use unix-style line termination -- line-feed only -- as opposed to dos/windows-style "CRLF")?
Re: Perl script shows source code
by Cody Pendant (Prior) on Oct 27, 2007 at 20:53 UTC
    If you can't get perl working outside the cgi-bin folder, another approach is to have an HTML file which contains an include like <!--#exec cgi="/cgi-bin/yourscript.pl"--> that facility may not be turned on either, and it won't be ideal if you want to do anything with headers, like set a cookie for instance, but otherwise it's a useful workaround.


    Nobody says perl looks like line-noise any more
    kids today don't know what line-noise IS ...
Re: Perl script shows source code
by andyford (Curate) on Oct 27, 2007 at 14:55 UTC

    Please show us the smallest possible bit of working code so that we can give specific advice. The answer right now would be, "It Depends".

    non-Perl: Andy Ford

Re: Perl script shows source code
by snopal (Pilgrim) on Oct 27, 2007 at 14:18 UTC

    Your output needs to lead with:

    Content-Type: text/html

    followed by a blank line.

    The truth is this is the most basic of issues in CGI development and is supplied in every article or book regarding the issue.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://647574]
Approved by graff
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2024-03-28 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found