Perl scripts won't run on Linux 
Author Message
 Perl scripts won't run on Linux


[posted and cc]

Quote:
> I've just set up at a Linux box as an intranet server. Perl seems to be
> installed ok, but I can't seem to run scripts. The GNU C compiler is
> installed and I've made sure the scripts are executable, but when I give
> the command to run them, I get this message:
> $ bash: command not found <scriptname>

> Is there a config file I need to modify? Any suggestions would be
> appreciated. Thanks in advance.

Make sure that the directory that the script is in is in the path (or give
an explicit path in the invokation).

--
Mother is the name for GOD on the lips and
hearts of all children.  - Eric Draven



Tue, 13 Nov 2001 03:00:00 GMT  
 Perl scripts won't run on Linux
I've just set up at a Linux box as an intranet server. Perl seems to be
installed ok, but I can't seem to run scripts. The GNU C compiler is
installed and I've made sure the scripts are executable, but when I give
the command to run them, I get this message:
$ bash: command not found <scriptname>

Is there a config file I need to modify? Any suggestions would be
appreciated. Thanks in advance.

Jay Oram

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Wed, 14 Nov 2001 03:00:00 GMT  
 Perl scripts won't run on Linux

Quote:

>I've just set up at a Linux box as an intranet server. Perl seems to be
>installed ok, but I can't seem to run scripts. The GNU C compiler is
>installed and I've made sure the scripts are executable, but when I give
>the command to run them, I get this message:
>$ bash: command not found <scriptname>

It could be one of the classics ;

1) the first line of the script doesn't have the correct path to Perl i.e.

#!/usr/bin/perl -w

2) you don't have '.' (current directory) in your path which means you need to
run the program as ;

./program

HTH.

--

Alastair




Wed, 14 Nov 2001 03:00:00 GMT  
 Perl scripts won't run on Linux
: I've just set up at a Linux box as an intranet server. Perl seems to be
: installed ok, but I can't seem to run scripts.

   Since you say "seems to be", we are to assume that it is
   in some kind of "out of the box" setup and that you did not
   do a normal install yourself?

   (some distributions don't keep up with recent versions of perl)

: The GNU C compiler is
: installed and

   If perl has already been built then you don't need a C compiler
   anyway (may be needed for installing some non-bundled modules).

: I've made sure the scripts are executable, but when I give
: the command to run them, I get this message:
: $ bash: command not found <scriptname>

: Is there a config file I need to modify?

   No.

: Any suggestions would be
: appreciated. Thanks in advance.

   1) See if perl is installed somewhere in your path:

      which perl

         1.1) if that doesn't find anything, then you need to
              go root around and find out where it got installed.
              (look in /usr/bin/ and /usr/local/bin/ et al)

   ( assume perl is installed at:      /usr/bin/perl  for the below)

   2) Find out what version you have, and see if perl will
      execute at all:

      /usr/bin/perl -V

      or

      /usr/bin/perl -v

      Decide if it is a "recent enough" perl version.

      If not, then go to CPAN and get a newer perl.

   3) Try giving the script directly to perl:

     /usr/bin/perl -w scriptname

   If all of that works, then it seems that the essentials are in place.

   Then just adjust your path, shebang line etc to suit your tastes.

--
    Tad McClellan                          SGML Consulting

    Fort Worth, Texas



Wed, 14 Nov 2001 03:00:00 GMT  
 Perl scripts won't run on Linux

Quote:

> I've just set up at a Linux box as an intranet server. Perl seems to be
> installed ok, but I can't seem to run scripts.

Why do you think that perl is properly installed?  I'm just being the
devil's advocate on this one.

Quote:
> The GNU C compiler is installed

Are we talking perl or C?  This is not important.

Quote:
> and I've made sure the scripts are executable,

Good, that is a common error.

Quote:
> but when I give
> the command to run them, I get this message:
> $ bash: command not found <scriptname>

There are two ways I can get that message.  One is to put it in my PATH,
but to not rehash things.  That is basically BASH not finding the
script.  Use an explicit path (~/bin/script_name) to get around that
one.

If it still doesn't work, your problem is that your path to the perl
interpreter inside the script is bad.  The rules for the this are (more
or less - this is off the top of my head)

if the first byte of the file (first character on first line) is a "#",
the it is a script.  If the second byte is a white space (blank, \n,
etc) it is a script for the interpreter specified in the $SHELL
variable.  If that second byte (second character on first line) is a "!"
then what follows is the explit path to the interpreter.  After that can
come optional switches.

This means your file should start with something like

        #!/usr/bin/perl -w

Of course, if your perl is installed in /usr/local/bin/perl, /bin/perl
or even /tmp/perl_with_a_strange_name, you will need to modify your #!
line accordingly.  My advice is to ensure that /usr/bin/perl and
/usr/local/bin/perl *both* point to a working copy of perl.  I have one
be a symlink to the other (I used to install in /usr/local/bin/perl, but
now I use /usr/bin/perl).

Note that when installing Perl, you get options as to where to put it,
and an option to create a link from /usr/bin/perl to wherever you chose,
so you should have seen this if you installed it yourself.  Well, I got
that prompt with the 5.004 release, I haven't upgraded in a while.

Quote:
> Is there a config file I need to modify? Any suggestions would be
> appreciated. Thanks in advance.

Sure enough.  I have used Perl on Linux since I got around to installing
Linux back in the 1.2.* days.  Perl worked perfectly and I have never
had any Linux specific problems.  There is no reason to think that Linux
and Perl don't play together well.

- doug



Sat, 17 Nov 2001 03:00:00 GMT  
 Perl scripts won't run on Linux

Quote:

>I've just set up at a Linux box as an intranet server. Perl seems to be
>installed ok, but I can't seem to run scripts. The GNU C compiler is
>installed and I've made sure the scripts are executable, but when I give
>the command to run them, I get this message:
>$ bash: command not found <scriptname>

>Is there a config file I need to modify? Any suggestions would be
>appreciated. Thanks in advance.

>Jay Oram

The current directory is NOT automatically in your path.  Try ./scriptname
and make sure that the script has read and execute permission (typically
755).

--

http://www.xnet.com/~efflandt/



Mon, 19 Nov 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Please Help:My script runs on win32, it won't run on Unix

2. My script runs on win32, it won't run on Unix

3. Please Help: My script runs on win32, it won't run on Unix

4. perl 4 script that won't run under perl 5

5. script won't run...displays script text

6. Perl CGI scripts won't run without -w switch (under Apache 1.3.x)

7. IIS4.0 won't run perl scripts which call external commands

8. perl script won't run correctly inside emacs

9. Server won't run Perl scripts (Fasttrack)

10. Server won't run Perl scripts

11. Cron won't run my Perl Script

 

 
Powered by phpBB® Forum Software