Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Maybe someone here would be able to help me out. Have installed Ubuntu 12.04 LTS (kubuntu) on two machines. The .bashrc and .bash_profile files are identical as the file structures on each machine is the same.

On machine 1 I run bash scripts within a terminal window with the simple: ./scriptname.sh

On machine 2, I cannot do this and must use: sh scriptname.sh Nor can I use ./ and tab-complete the script filename.

All executable bits are set correctly, all files and folders have the correct permissions. In the header of the scripts the shebang is set correctly.

Any ideas why this would be occurring?

Cheers

share|improve this question
    
also asked on unix&linux and stackoverflow –  glenn jackman Nov 5 '12 at 1:50
    
Is this for root, or a non-root user? Does echo $SHELL on both machines confirm that the shell is bash? –  Lars Rohrbach Nov 5 '12 at 1:56
    
non-root user, echo $SHELL returns /bin/bash on both machines –  adeliefan Nov 5 '12 at 2:01
add comment

3 Answers

The only thing that would cause this is if the script is not executable. I know you said the executable bit is set, but make sure:

chmod +x scriptname.sh
share|improve this answer
    
Nope - its definitely set right. I figure there has to be something wrong with my environmental set up (.bashrc or .bash_profile) but cant see where it has snuck in. –  adeliefan Nov 5 '12 at 2:08
add comment

I've read of various problems arising with auto-completion, not necessarily with 12.04, and the following two options seem worth trying:

First, try disabling bash programmable completion: Comment-out these three lines in both /etc/bash.bashrc and in the user's $HOME/.bashrc:

 if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
     . /etc/bash_completion
 fi

You may find that those lines are already commented-out with # in front, in which case just leave it as-is.

So secondly, try re-installing bash-completion:

sudo apt-get purge bash-completion
sudo mv /etc/bash_completion.d /etc/bash_completion.d.bak
sudo apt-get install bash-completion
share|improve this answer
    
Thanks for the suggestion Lars, it made no difference though. –  adeliefan Nov 5 '12 at 2:18
    
Well, darn. I presume you re-logged-in after doing this? –  Lars Rohrbach Nov 5 '12 at 2:27
add comment

The errors you see may be caused by trying to run an executable on a media mounted with the "noexe" property. Type mount, and examine the properties of the device which contains the script. Change the /etc/fstab properties of the mount if necessary.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.