Make sh executable as like exe in window

4.1k views Asked by At

I have one Shell script file. Inside it, I have create one text file in same folder where sh file is placed.

I want to run sh file on double click. When user double click on sh file then sh file will be execute and one text file should be generated in same dir.

I know i can make executable file using: chmod +x myfile.sh but problem is:

when I run this file on other Machine or same Machine with different drive, I Need to make again executable. I want behavior just like "exe file" in Windows.

2

There are 2 answers

2
tripleee On

If you copy the file to a drive whose filesystem doesn't support the Linux permissions model, you will lose these permissions. The solution is to use a Linux-friendly filesystem instead (reformat the drive, use e.g. ext2 filesystem), but a less intrusive workaround is to store the file in a container which does preserve permissions (such as a tar file) and extract it from there to the target system(s).

If you need to support users who can only learn to click and drag with the mouse, only the first option is viable.

If the target systems have Internet access, perhaps the simple way forward is to put the file on a server, and just put a text file with the download URL on the stick.

2
vahnevileyes On

Can you right click the file and select properties. Check the box that says Allow executing file as a program.