Dilletante Dilletante - 8 months ago 47
Bash Question

I want a shell script to be executable but not readable

I created a script which I want other users on our shared system to execute but not read. I set the permissions as executable for all but revoked the R/W rights.

---x--x--x 1 dilletante staff 0 2013-04-02 11:42 expect.sh

However the script Fails to execute...The reason is simple.. The interpreter also needs to read the script

I want a workaround if any..Can I embed it into some compiled language..Would that work?
If yes, could you point to the resources where I can learn how to do so..


The shell has to be able to read a script to execute it. You are asking for the impossible if it is a script.

You can certainly use 111 permission on an executable program (as produced by the ld command, typically invoked by the compiler of your chosen compiled implementation language). The owner can always change the permission to read the program if they want to, but it is more conventional to use 511 than 111 permission.

There are often compilers for a specific script language that will generate a C program equivalent to the script: