1

I'm getting command not found errors on all my scripts I try to run since upgrading. For instance if I navigate to a directory in terminal and then try to execute a script I receive this error. The scripts do have executable permissions.

I did mess around with my path at one point, I don't know if I've messed it up somehow?

    # if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin"
fi

Update If I run the scripts with "bash" in current dir in the terminal the scripts run i.e. bash myscript, however without it I still get command not found error. Would this imply bash is no longer in my path? If so how do I fix this?

Results of echo $PATH

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
7
  • 1
    Do you have it set as executable?
    – Mitch
    May 2, 2013 at 9:30
  • yup! double checked via terminal and the gui
    – KingFu
    May 2, 2013 at 9:40
  • Ubuntu 13.04 comes with Python 3 by default. If your scripts are written in Python 2 you may need to manually install it. Please check this out for reference wiki.ubuntu.com/RaringRingtail/ReleaseNotes#Python_3.3
    – user154755
    May 2, 2013 at 10:06
  • @WarrenHill I'm trying to run scripts by navigating to their directory in terminal and executing them by typing their name. This used to work but now the only way I can execute them is by putting bash infront
    – KingFu
    May 2, 2013 at 10:41
  • @WarrenHill one script has #!/bin/bash and another script has #!/bin/sh. Running ls -l on one of the scripts gives -rwxrwxrwx. If you look at my question i've updated with teh results of echo $PATH. Am I right in saying /bin/bash should be in the results but isn't?
    – KingFu
    May 2, 2013 at 11:10

1 Answer 1

1

Pretty sure I have spotted a mistake.

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin"
fi

Does not include the users private bin in the path. Your path is just $HOME/bin

Try this instead

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

You can confirm if this is the problem with echo $PATH but as the path you have posted looks OK this tells me that you dont have a $HOME/bin directory.

1
  • Thanks have changed PATH to 'PATH="$HOME/bin:$PATH"' and rebooted. Sadly still getting the same error. The results of 'echo $PATH' are: '/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games'
    – KingFu
    May 2, 2013 at 10:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .