Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

I can see my perl code - script isn't executing

by Anonymous Monk
on May 16, 2008 at 20:25 UTC ( #687016=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Am I missing something?

I've been programming perl for *years*. Maybe I'm just tired or something, but I am not able to get my program to execute. I thought that maybe the first line in the program was wrong but I tried both #!/usr/bin/perl and #!/user/local/bin/perl. in both cases when I enter the path to the script in the browser, I can see my perl code and not the execution.

Any suggestions? Here is the (very simple code):

#!/usr/bin/perl #testing print "Content-type: text/html\n\n"; print "Welcome!";

Comment on I can see my perl code - script isn't executing
Download Code
Re: I can see my perl code - script isn't executing
by psini (Deacon) on May 16, 2008 at 20:35 UTC

    I had a similar problem once or twice and took me ages to find out that if you edit a file on (most) windows editor and then try to run it on linux, the extra <LF> at end of line prevents the correct interpretation of #!/usr/bin/perl

    Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.

      ... but this not unexpectedly, normally results in a 'not found' error being returned by the shell.

      At last, a user level that best describes my experience :-))
Re: I can see my perl code - script isn't executing
by Anonymous Monk on May 16, 2008 at 20:45 UTC
    Psini, Thanks so much for your response, but I didn't paste this from a windows document. I just used vi and typed up the script.

    I went back and deleted the first line and then typed it in again just to make sure. I am still getting the same problem.

      Did you try to exec it from command line?

      If it works, the problem probably is in apache configuration

      Two suggestions: (1) if the file is the wrong dir apache may be not allowed to execute it. (2) I know it is stupid but are you sure that file has eXecute permission for apache user?

      Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.

Re: I can see my perl code - script isn't executing
by ikegami (Pope) on May 16, 2008 at 21:07 UTC

    I can see my perl code and not the execution.

    That's a server configuration issue. It needs to know that files in a certain directory or with a certain extension are to be treated as CGI scripts. Consult your web service's documentation, their tech support, or your server's configuration documentation if you run your own server.

Re: I can see my perl code - script isn't executing
by Joost (Canon) on May 16, 2008 at 22:01 UTC
    As stated above, you need to have your webserver configured so that it executes your file as a CGI script. Assuming you're using apache, see this page.

    In short: make sure your script is executable by the webserver (usually chmod 755 scriptname and the same for the path it's in), and that either ExecCGI option is enabled for the path and that the script's extension has a cgi-script handler or that the directory the script is in has a ScriptAlias directive.

Re: I can see my perl code - script isn't executing
by cLive ;-) (Parson) on May 16, 2008 at 22:18 UTC

    Run your script using ./scriptname.pl (rather than "perl scriptname.pl") - if it fails, check shebang line and permissions.

    Otherwise, tail your apache logs and see what they say. Check ExecCGI is enabled for the directory, Also check conf files (including any .htaccess files in the path to script).

Re: I can see my perl code - script isn't executing
by Bloodnok (Vicar) on May 17, 2008 at 13:14 UTC
    Further to the above suggestions, does the perl binary have at least 755 permissions - altho' the script may be readable by everyone, the compiler/interpreter may not.

    Just a thought ...

    At last, a user level that best describes my experience :-))
      If that were the case he'd get some kind of permission denied error, not a dump
        He doesn't say he's getting a dump.

        At last, a user level that best describes my experience :-))

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-07-25 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls