Results 1 to 4 of 4

Thread: Default shebang and executing a shell script

  1. #1
    Join Date
    Oct 2011
    Beans
    13

    Default shebang and executing a shell script

    Hi there.

    I've read on this website that:

    If you do not specify an interpreter line, the default is usually the /bin/sh. But, it is recommended that you set #!/bin/bash line.
    And my first question is: Is there a way to find out which shell is the default one in case of shebang on Ubuntu? I suppose it's sh (which is linked to dash), but is there an official way to check it (and maybe change it as well)?

    In Ubuntu, running a file with execute permission bit set opens a window with Run in Terminal, Display, Cancel and Run options available.

    If the first one is chosen and no shebang is specified in the file, I suppose that the script will be executed by sh->dash as the BASH variable is unset upon execution.

    My second question is that why choosing the Run option produces no action? Nothing happens, regardless of whether I put the shebang line into the script or not...

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Default shebang and executing a shell script

    does your script wait for input at the end? because terminal window closes as soon as script ends.

    try this:
    Code:
    #!/bin/bash
    
    echo this is my script
    read -p "Press [ENTER] to continue "
    running scripts from gui is lame either way
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    Oct 2011
    Beans
    13

    Re: Default shebang and executing a shell script

    Yes, it does, but in case of the Run option still nothing happens.

  4. #4
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Default shebang and executing a shell script

    The script prints a message on standard output which is console (terminal) by default. If you are not specifying Run in terminal when running it from GUI, it will have neither terminal to write onto nor one to read input from, so all input and output will be discarded.

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
  •