Find the answer to your Linux question:
Results 1 to 4 of 4
Hello, When I try to run a script like this, it failed: $ ./hello_world.sh bash: ./hello_world.sh: /bin/sh: bad interpreter: Permission non accordée I must run the script like this: $ ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! YuGiOhJCJ's Avatar
    Join Date
    Sep 2010
    Posts
    6

    [SOLVED] Problem running scripts


    Hello,

    When I try to run a script like this, it failed:
    $ ./hello_world.sh
    bash: ./hello_world.sh: /bin/sh: bad interpreter: Permission non accordée

    I must run the script like this:
    $ bash ./hello_world.sh
    Hello World!

    This is the script:
    $ cat hello_world.sh
    #!/bin/sh
    echo Hello World!

    These are the permissions:
    $ ls -l hello_world.sh
    -rwxr-xr-x 1 yugiohjcj yugiohjcj 28 Sep 25 18:23 hello_world.sh

    And this is my user identity:
    $ id
    uid=1000(yugiohjcj) gid=1000(yugiohjcj) groups=20(dialout),24(cdrom),25(floppy),29(audio), 44(video),46(plugdev),1000(yugiohjcj)

    Can you explain me why I can't run this script like the first try?

    Thank you.

  2. #2
    Linux Newbie sarlacii's Avatar
    Join Date
    May 2005
    Location
    South Africa
    Posts
    110
    Hi YuGiOhJCJ

    Check your script...

    Quote Originally Posted by YuGiOhJCJ View Post
    This is the script:
    $ cat hello_world.sh
    #!/bin/sh
    echo Hello World!
    You should have #!/bin/bash in place of #!/bin/sh.

    The second attempt works because you force bash to be the interpreter.
    Respectfully... Sarlac II
    ~~
    The moving clock K' appears to K to run slow by the factor (1-v^2/c^2)^(1/2).
    This is the phenomenon of time dilation.
    The faster you run, the younger you look, to everyone but yourself.

  3. #3
    Just Joined! YuGiOhJCJ's Avatar
    Join Date
    Sep 2010
    Posts
    6
    It doesn't resolve the problem.

    This is the new content of the script:
    $ cat hello_world.sh
    #!/bin/bash
    echo Hello World!

    And when I try to run it like this:
    $ ./hello_world.sh
    bash: ./hello_world.sh: /bin/bash: bad interpreter: Permission non accordée

    But if I run it like this:
    $ bash ./hello_world.sh
    Hello World!

    Can you help me to run my script like the first try?

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined! YuGiOhJCJ's Avatar
    Join Date
    Sep 2010
    Posts
    6

    Smile

    I found the solution on the Internet: edit my /etc/fstab file.

    I must replace this:
    eeepc.geekdomain:/home /home nfs defaults,user 0 0
    by this:
    eeepc.geekdomain:/home /home nfs defaults,user,exec 0 0

    The 'exec' option is what I need

    Problem resolved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •