-3

I have faced this following error while i am trying to run a software :

/afs/cern.ch/work/a/atnourji/ROOTAnalysisTutorial/build/atlas_build_run.sh: line 16: /usr/bin/bash: No such file or directory

Any advise for this matter are very appreciated ?

$ nano /afs/cern.ch/work/a/atnourji/ROOTAnalysisTutorial/build/atlas_build_run.sh :

#!/user/bin/bash

# Transmit errors: set -e

# Set up the environment: source /afs/cern.ch/work/a/atnourji/ROOTAnalysisTutorial/build/x86_64-centos7-gcc62-opt/setup.sh || exit 1

# Run the command: exec $* || exit 1 ~
  • *Does* `/usr/bin/bash` exist? The location of your shell is different between different machines. `#!/usr/bin/env bash` is generally a better alternative (searching the PATH to try to find a copy of `bash`), assuming your OS provides `/usr/bin/env`. – Charles Duffy Oct 07 '19 at 20:37
  • BTW, `exec $*` is **very** buggy. You should probably be running `exec "$@"` instead. – Charles Duffy Oct 07 '19 at 20:37
  • ...to prove what I mean about `exec $*` being buggy, try running the command `printf '%s\n' "first line" "second line" '*'` through this wrapper after you fix the initial "no such file or directory" issue. – Charles Duffy Oct 07 '19 at 20:39
  • (BTW, it's also [not great practice to use file extensions on executables](http://www.talisman.org/~erlkonig/documents/commandname-extensions-considered-harmful/); just name it `atlas_build_run`, and then you aren't under any obligation to rename it, and force all your users to change how they call it, if you ever rewrite it in a different language; and you also aren't falsely implying that a *bash* script is compatible with *sh*, which is a different, simpler language). – Charles Duffy Oct 07 '19 at 20:40
  • (Also, use `|| exit` instead of `|| exit 1` and you'll pass through the exact exit status of the component that failed, instead of masking that exact status and forcing it always to be `1`). – Charles Duffy Oct 07 '19 at 20:42
  • 1
    On Linux Mint, bash is '/bin/bash'. I'm sure most distro will follow, and env is /usr/bin/env – dash-o Oct 07 '19 at 20:43
  • 6
    `user` != `usr`. Check the shebang. – William Pursell Oct 07 '19 at 20:47

1 Answers1

0

I'd recommend using #!/usr/bin/env bash as the shebang (disclaimer: my answer). /user with an "e" is not a standard *nix path.

l0b0
  • 55,365
  • 30
  • 138
  • 223
  • The error message they copied-and-pasted using `usr` implies that `user` was a typo in asking the question, vs part of their actual usage. Thus, this looks like a `/bin/bash`-vs-`/usr/bin/bash` issue, vs a `/user`-vs-`/usr` issue. – Charles Duffy Oct 07 '19 at 22:40