executable in path, findable by which, yet cannot execute without fully qualifying path?

Posted by Peeter Joot on Server Fault See other posts from Server Fault or by Peeter Joot
Published on 2012-04-11T23:50:28Z Indexed on 2012/04/12 5:33 UTC
Read the original article Hit count: 549

Filed under:
|

I've got a bizarre seeming shell issue, with a command in the $PATH that the shell (ksh, running on Linux) appears to cowardly refuse to invoke. Without fully qualifying the command, I get:

#  mycommand
/bin/ksh: mycommand: not found [No such file or directory]

but the file can be found by which:

#  which mycommand
/home/me/admbin/mycommand

I also explicitly see that directory in $PATH:

#  echo $PATH | tr : '\n' | grep adm
/home/me/admbin

The exe at that location seems normal:

#  file /home/me/admbin/mycommand
/home/me/admbin/mycommand: setuid setgid ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.4, dynamically linked (uses shared libs), not stripped

# ls -l mycommand  
-r-sr-s--- 1 me mygroup 97892 2012-04-11 18:01 mycommand

and if I run it explicitly using a fully qualified path:

#  /home/me/admbin/mycommand

I see the expected output. Something is definitely confusing the shell here, but I'm at a loss what it could be?

EDIT: finding what looked like a similar question: Binary won't execute when run with a path. Eg >./program won't work but >program works fine

I also tested for more than one such command in my $PATH, but find only one:

# for i in `echo $PATH | tr : '\n'` ; do test -e $i/mycommand && echo $i/mycommand ; done
/home/me/admbin/mycommand

© Server Fault or respective owner

Related posts about linux

Related posts about ksh