Ubuntu – making a bash script executable programatically

bashexecutablescripts

I need to create a bash script to create and mount a drive. So, two simple commands. Both "work" when entered at the command line.

The script is created and executed every time a normal user logs in, so I need a method to make this script executable at that time. So far, I cannot get this to work. For example, the first part mkdir /vvv/gggg doesn't proceed because the script is not executable (I'm guessing).

Hope this makes sense. Is this possible? Any thoughts on how to make this work will be appreciated.

Update:

Thanks for your responses. I probably should add some additional information other than that I'm new to Linux.

I'm using an open source virtual desktop application called Ulteo. This App runs on top of Ubuntu and has very little support – that why i'm here. Basically, I'm learning by fire.

So, there application has a login script management function where I can tie a script to a user. A simple windows script with net use works perfectly fine. However, when I try to apply a Linux bash script nothing happens.

I'm thinking that because I need to perform a chmod +x against the script first to make the script executable, this is why its failing. By the way, Ulteo runs in a chroot jail. I've created a script, saved it and could not find the script. I searched both inside and outside the chroot jail.

I like the approach by dan08 to have the initial script reference another script that i can find and make executable manually. Would I run into the same problem?

Does this additional information clarify the situation? Thanks in advance.

Photos attached.

![login scipt management console][1]

![windows scripts that work][2]

![simple linux script that doesn't work][3]

Sorry I Can't post images yet

Best Answer

There are two things you need to do:

  1. Reference the script interpreter at the beginning of the script:

    #!/bin/bash
    
  2. Set the permissions to make it executable:

    chmod +x myscript.sh