in reply to Permissions for a separately installed perl

What do you get for

$ ls -l /opt/perl/bin/perl $ which -a perl

The shell's search behavior (mimicked by which) is to skip programs if their binary isn't executable for the user in question, even if it comes earlier in $PATH.

P.S.: it's usually not a good idea to make directories like /opt/perl world-writable...

Replies are listed 'Best First'.
Re^2: Permissions for a separately installed perl
by wfsp (Abbot) on Feb 28, 2010 at 12:31 UTC
    $ ls -l /opt/perl/bin/perl -rwxr-xr-x 2 john john 1169915 2010-02-28 10:30 /opt/perl/bin/perl $ which -a perl /usr/local/bin/perl /usr/bin/perl

      Ok, in that shell, what does

      perl -e 'print "$]\n";'

      yield?

      The shell hashes paths to commands, and if you add a command to a path previous in $PATH to the already hashed one, your may not see the changes:

      qwurx [shmem] ~> touch blorflydick qwurx [shmem] ~> rm blorflydick qwurx [shmem] ~> mkdir bin qwurx [shmem] ~> PATH=$HOME/bin:$PATH qwurx [shmem] ~> which rm /bin/rm qwurx [shmem] ~> echo '#!/bin/sh' > bin/rm qwurx [shmem] ~> echo 'echo no rm damnit' >> bin/rm qwurx [shmem] ~> chmod a+x bin/rm qwurx [shmem] ~> which rm ~/bin/rm qwurx [shmem] ~> rm blorflydick rm: cannot remove `bloflydick': No such file or directory qwurx [shmem] ~>

      A new shell will see the changes, however:

      qwurx [shmem] ~> echo $SHLVL 4 qwurx [shmem] ~> bash qwurx [shmem] ~> echo $SHLVL 5 qwurx [shmem] ~> rm blorflydick no rm damnit qwurx [shmem] ~>
        A new shell will see the changes

        or

        $ hash -r

        to make bash forget its cached bindings.

      Hm... another try:

      $ strace -f -efile /bin/bash -c 'perl -v' 2>&1 | grep perl
        $strace -f -efile /bin/bash -c 'perl -v' 2>&1 | grep perl execve("/bin/bash", ["/bin/bash", "-c", "perl -v"], [/* 17 vars */]) = + 0 stat64("/usr/local/sbin/perl", 0xbfde45f8 = -1 ENOENT (No such file or + directory) stat64("/usr/local/bin/perl", {st_mode=S_IFREG|0755, st_size=1169915, +...}) = 0 stat64("/usr/local/bin/perl", {st_mode-S_IFREG|0755, st_size=1169915, +...}) = 0 execve("/usr/local/bin/perl", ["perl", "-v"], [/* 16 vars */]) = 0 This is perl, v5.10.1 (*) built for i686-linux... etc.
      Also try
      sudo which perl
      I think it's a matter of what's in PATH.