Arduino (1) Bugs (3) C (1) Install (3) Linux (25) Python (10) Raspberry Pi (4)

Monday, 5 December 2016

Creating a excutable shell script

When writing shell scripts you can use .sh file extension and run using the sh command.

You can make your shell script executable and run using ./

To make it like this we need to do 2 things:
Change the file permissions
Define the interpreter/shell we will be using in the script.

Changing the file permissions:
Run the command:
chmod 0755
This will allow all users to run the script

To only allow the current user to run the script run:
chmod 0700

Defining the shell within the script:
Add the following line to the start of the script
Depending on which one you are using.

Now you can run your script by typing