Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When executing a script from the path (scriptname, rather than "sh scriptname") I receive the following error:

-bash: ./gitup: /bin/bash/: bad interpreter: Not a directory

All of the other scripts in the same directory execute without issue, and I do not encounter this issue when the script is executed manually (sh scriptname), only when executed by itself. So the script, itself, seems to not be the issue as it does execute normally, and did so until I opened a new shell session and encountered this error for this script alone.

The script is executable, includes all requisite lines to execute in the way I've described (it worked properly until earlier today) and is able to be executed by my user, so I am unsure of what the issue could be.

The shebang line reads #!/bin/bash. I used the command "export PATH=$PATH:repos/utilities " to direct to the directory storing these scripts, all of which, besides this one, execute simply by calling the script name (i.e. gitup).

share|improve this question
3  
Could you please include at least the first line (the shebang line) of your script and the command you use to call it? You said it is in your path, yet you call it with ./gitup. Are you sure you are running the script you think you are? –  terdon Jan 28 '13 at 21:37

2 Answers 2

up vote 1 down vote accepted

There are a few things I can think of.

  1. You said your script is in your $PATH, yet you call it with its full path (./gitup as opposed to just gitup). Could it be that you have edited one version of the script (the one in your $PATH, say ~/bin/gitup) and have then executed another (./gitup)?

  2. Could there be multiple versions in your $PATH? You can check with

    which -a gitup
    
  3. You may have inadvertently entered a strange invisible character while editing the script. Check the shebang line using od:

    head -1 ./gitup | od -c
    

    Make sure there is nothing after #!/bin/bash but the newline character (\n). It should look like this:

    0000000   #   !   /   b   i   n   /   b   a   s   h  \n
    0000014
    
share|improve this answer
    
Thank you. It looks like there were multiple paths to the same script. –  tony_perkis666 Jan 28 '13 at 22:06

Check the shebang (#!) line, make sure that it says

#!/bin/bash

and not

#!/bin/bash/

If it looks like the second example, change it to the first.

EDIT(in response to this comment)

If this is limited to only one script, make a copy of this script, and start removing code from it, and make a minimal script that still shows this problem. Then post that minimal script.

share|improve this answer
    
I thought that at first and verified it was using: #!/bin/bash which is why I'm so baffled by this. –  tony_perkis666 Jan 28 '13 at 21:35
    
@josephmarhee Is /bin/bash a symlink to /bin/bash/? Does /bin/bash exist? Is your system up-to-date (a weird bug)? –  BenjiWiebe Jan 28 '13 at 21:37
    
It doesn't appear to be symlinked, but /bin/bash does exist; this seems limited to just the one script, but nothing in the script seems to be the issue. I'll run an update and see what comes of it. Thanks. –  tony_perkis666 Jan 28 '13 at 21:41
    
@josephmarhee See my edit –  BenjiWiebe Jan 28 '13 at 21:44
    
Thank you. I'm going to mess with the script and see what comes of it. It is likely something somewhere in there that got edited at some point, so hopefully it is that. –  tony_perkis666 Jan 28 '13 at 22:00

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.