Results 1 to 10 of 10

Thread: How to create just an executable bash script

  1. #1
    Join Date
    May 2007
    Beans
    115
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    How to create just an executable bash script

    I am a newbie in scripting. I have this silly doubt.
    Do I need to give both read and execute permissions for a script to make it executable. Can't I just give execute permissions to it (without read and write)?

    Then how to make a script so that except for the admin no other user can see the script or modify the script but can only excecute it.

    Any inputs on this would be highly appreciated.

  2. #2
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

  3. #3
    Join Date
    May 2007
    Beans
    115
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: How to create just an executable bash script

    Quote Originally Posted by sisco311 View Post
    Thank you sisco311. Yes I know about changing permissions. But I cant make them execute the bash script, even after giving the execute permission. That is my issue. I even have to give the read permission too. That beats me.

  4. #4

    Re: How to create just an executable bash script

    bash (or any other interpreter) needs to read the script to execute it.

  5. #5
    Join Date
    Aug 2006
    Beans
    196

    Re: How to create just an executable bash script

    When you make a bash script, and make it executable, you are not really executing it, you are invoking bash, and feeding the script to it in stdin.
    The logic looks kinda like this:
    # ./script.sh
    if x bit set && first chars of file "#!" then run the command on first line <the script.

    to make an executable that cannot be read, you need to make a real executable.

  6. #6
    Join Date
    May 2007
    Beans
    115
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: How to create just an executable bash script

    Quote Originally Posted by Tuna-Fish View Post
    When you make a bash script, and make it executable, you are not really executing it, you are invoking bash, and feeding the script to it in stdin.
    The logic looks kinda like this:
    # ./script.sh
    if x bit set && first chars of file "#!" then run the command on first line <the script.

    to make an executable that cannot be read, you need to make a real executable.
    Thank you that makes sense.

  7. #7
    Join Date
    Feb 2010
    Beans
    80

    Re: How to create just an executable bash script

    the question was never answered. how to create a real executable from a bash script?

  8. #8
    Join Date
    Aug 2007
    Beans
    949

    Re: How to create just an executable bash script

    You misunderstand the question. To create an executable bash script, you simply put the following line as the first line (indicates the appropriate interpreter) and set the permissions to read-execute.

    Code:
    #!/bin/bash

  9. #9
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,292
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to create just an executable bash script

    Quote Originally Posted by Tuna-Fish View Post
    When you make a bash script, and make it executable, you are not really executing it, you are invoking bash, and feeding the script to it in stdin.
    Wrong. You are passing the name of the file as an argument, not passing its contents on stdin.

    EDIT: Meh, necromancy...

    Quote Originally Posted by erjoalgo View Post
    the question was never answered. how to create a real executable from a bash script?
    Define "real executable"?
    Last edited by Bachstelze; August 31st, 2010 at 04:50 AM.
    「明後日の夕方には帰ってるからね。」


  10. #10
    Join Date
    Feb 2010
    Beans
    80

    Re: How to create just an executable bash script

    compiled machine binary code

Bookmarks

Posting Permissions

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