2

I have an executable script install_packages.sh in /home/etienne/admin folder. The directory's path is added to $PATH variable from /etc/bash.bashrc. When I type #echo $PATH I see that the variable does contain the directory's path. However, when I try to run the script from other directories, shell says that command not found. From within own directory, the script runs fine if call it as ./install_packages.sh. The script itself is ordinary - it contains only apt-get install <package> lines. I am really baffled


Output of the echo $PATH | xxd

0000000: 2f68 6f6d 652f 6461 6e69 656c 2f61 646d  /home/etienne/adm
0000010: 696e 3a2f 7573 722f 6c6f 6361 6c2f 7362  in:/usr/local/sb
0000020: 696e 3a2f 7573 722f 6c6f 6361 6c2f 6269  in:/usr/local/bi
0000030: 6e3a 2f75 7372 2f73 6269 6e3a 2f75 7372  n:/usr/sbin:/usr
0000040: 2f62 696e 3a2f 7362 696e 3a2f 6269 6e3a  /bin:/sbin:/bin:
0000050: 2f75 7372 2f67 616d 6573 3a2f 7573 722f  /usr/games:/usr/
0000060: 6c6f 6361 6c2f 6761 6d65 730a            local/games.
  • Please, add the output of echo "$PATH" | xxd to the question. Also, check that the error isn't coming from inside of the script: doesn't it call a command that's not found? – choroba Apr 08 '15 at 09:06
  • At the moment script contains only apt-get install lines. If I run them from the shell they work – Etienne Kahn Apr 08 '15 at 09:14
  • Do you get any error while running like ./install_packages.sh ? – heemayl Apr 08 '15 at 09:40
  • No at all. That's what frustrates me. – Etienne Kahn Apr 08 '15 at 09:43
  • Have you tried running hash -r? – choroba Apr 08 '15 at 09:58
  • 1
    You mention you run # echo $PATH, does that mean you are logged in as root? Are you running echo $PATH and install_packages.sh as the same user? Is either of the commands run with sudo? – terdon Apr 08 '15 at 09:59
  • Can you run it in other directories using full path, e.g. /home/etienne/admin/install_packages.sh? And do you have the full error message the shell complains? Sometimes the script may try to call itself with ./install_packages.sh. – user23013 Apr 08 '15 at 11:04
  • stupid question... but did you restart your shell after changing the PATH? – Alu Apr 08 '15 at 11:47
  • What happens if you copy the same file in /home.etienne/bin? Does it work then? – Fabby Apr 12 '15 at 10:13
  • are you typing ./install.sh or install.sh? – j0h Apr 17 '15 at 02:48

0 Answers0