我希望Shell脚本是可执行的,但不可读 [英] I want a shell script to be executable but not readable

查看:87
本文介绍了我希望Shell脚本是可执行的,但不可读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个脚本,希望我们共享系统上的其他用户执行但不读取.我将所有用户的权限设置为可执行,但撤消了R/W权利.

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..

推荐答案

shell必须能够读取脚本才能执行.您正在寻求不可能的脚本,而不是脚本.

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

您当然可以对可执行程序使用111权限(由 ld 命令产生,通常由您选择的已编译实现语言的编译器调用).所有者可以根据需要随时更改读取程序的权限,但是使用511比111的权限更为传统.

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.

通常有针对特定脚本语言的编译器会生成与脚本等效的C程序:

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

  • Compilers for shell scripts.
  • How to compile a Linux shell script as a binary.
  • Compiling shell scripts.
  • shc — shell script compiler.

等等.

这篇关于我希望Shell脚本是可执行的,但不可读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆