Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an executable shell script macOS that can be used on any computer

I have a shell file, and I need to make an executable that will work on any Mac without chmod +x, just by double clicking it. How can I do this? I've tried appify, but double clicking its result does not execute my file. I have also tried the solution presented in How to execute a shell script from within an app and show it in the terminal, but this results in the error Permission denied.

The script I'm trying to make executable is:

#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

cd $DIR

SLASH="/"

INFILE=`find $DIR -name "*.csv"`

DONE=`perl myfile.pl -i $INFILE -o output.csv -l $DIR$SLASH`

echo "File(s) are ready to use"

echo "Press [enter] to escape"

read terminate
like image 331
Aditya J. Avatar asked Dec 06 '25 19:12

Aditya J.


1 Answers

To make your file executable you need to add, surprisingly, the executable permission.

To do so you can run chmod +x filename.sh

This will make it so you can ./filename.sh and execute the file.

You'll see when you do a ls -lah that there will be an x added to the permissions on the left.

You can go further into user/group/world execution permissions, but that's another topic.

like image 79
darryn.ten Avatar answered Dec 08 '25 10:12

darryn.ten



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!