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

I uploaded my perl script to my server but cannot get it to run. I changed the permisions but still cannot get it to work. I know the scripts work because I took them down from the the same server. I tryed to run them through telnet to see if there was a problem but it tells me bash: script.pl: command not found. Any ideas? Thanks Scott

Replies are listed 'Best First'.
Re: Perl problems
by neshura (Chaplain) on Mar 09, 2000 at 07:30 UTC
    check the path in the first line of your scripts, make sure it is correct
    also run your script from the command line by saying "./script.pl" instead of "script.pl".
    if all else fails, post your code and describe the errors that you are getting when running from the browser

    e-mail neshura

Re: Perl problems
by Anonymous Monk on Mar 11, 2000 at 09:40 UTC
    I had the same problem just today. I tried chmod +x, and it still would just show the text of the perl script. The box I'm hosting the site on isn't mine, but my bosses and I wasn't sure which extentions he was allowing executable rights. I changed the .pl to .cgi and it worked like a charm. You need to ask the sysadmin what extentions are executable and where Perl is in case your first line is wrong. That was my first problem.
RE: Perl problems
by Anonymous Monk on Mar 10, 2000 at 06:38 UTC
    whereever you specified perl in the #! is wrong, you might have put #!/bin/perl but it is really in /usr/local/bin. do a which perl to find out where perl is on your ISP. gabe-san
      Someone suggested changing .pl to .cgi, so I did. I then ran the script through telnet and it ran like it was supposed to. However, when I tried to use my browsers it gives me an internal error message. I have never had a case where it would run through telnet and not the browser. Any thoughts??? Thanks Scott
        There are a *lot* of reasons why it would run correctly from the command line, but not run from your browser. Did you look in your server's error log? You should have an error message in there.

        Are the permissions set correctly? They should be 0755 so that the web server can execute your script.

        Did you output a content header?

        print "Content-Type: text/html\n\n";
        Read the Idiot's Guide.
RE: Perl problems
by Anonymous Monk on Mar 10, 2000 at 08:19 UTC
    what's the actual command you typed in to run the perl script?
RE: Perl problems
by Anonymous Monk on Mar 09, 2000 at 09:30 UTC
    I have heard that this kind of problem may be caused by ftp'ing the file in binary mode instead of text mode. Crazy? maybe if you are an old time Solaris admin, but this is what _appears_ to cause the problem on Linux
      yes, could be a transfer problem. Try to find out if the script first line contain at the end a \r character. You can see that viewing the script with some editor (joe, vim etc...), or viewing hexa). Also could be a path problem.
      If it is a ascii-binary transfer problem, you can quickly fix it (without uploading again) with perl -pi -e 's/\r//g' script.pl If that's not the problem, running the above command won't hurt anything anyway.
Re: Perl problems
by Anonymous Monk on Mar 10, 2000 at 04:33 UTC
    Everytime I have seen this error it was due to 1 of 2 things: (1) "." isn't in your path and you have to run the command using the form "./command.pl" or (2) the first line of the perl command was #!/bin/perl, for example, but there wasn't perl or a link to perl in /bin. You have to make sure the path is correct.
Re: Perl problems
by btrott (Parson) on Mar 09, 2000 at 23:20 UTC