8

所以我有一点 Linux 问题,天哪,这将教会我在 Windows 上花费这么多年。无论如何,我做了一个小的 java 应用程序,用 Java Service Wrapper 脚本很好地包装了,但是当我运行该脚本时:

sh ./wrapper.sh console

我马上就被拒绝了。权限被拒绝消息是这样的:

eval: 1: /home/user1/MyApp/bin/wrapper: Permission denied

我的小 wrapper.sh 位于 MyApp/bin 文件夹中。MyApp/bin/wrapper 目录包含 2 个文件:

  • 包装器-linux-x86-32
  • 包装器-linux-x86-64

作为测试,我运行了以下 chmod 命令:

chmod a=rwx MyApp -R

我验证了所有内容都是 rwx,即使在子文件夹中也是如此,并尝试再次运行脚本,结果完全相同......权限被拒绝。

有人知道我接下来可以尝试什么来让那个婴儿跑起来吗?

谢谢,兰斯洛特

4

6 回答 6

8

托管您的脚本的文件系统可能会使用该noexec标志挂载。检查该文件系统的 /etc/fstab 条目,如果有,请noexec尝试将其删除,然后通过重新挂载该文件系统mount /path/to/mountpoint -o remount

再三考虑,检查mount命令的输出是否有 noexec 实例而不是 /etc/fstab(文件系统可能已动态挂载。)

于 2009-04-07T23:19:23.673 回答
8

I just noticed the error message references the name of the directory hosting your file:

eval: 1: /home/user1/MyApp/bin/wrapper: Permission denied

We know it's a directory since you mentioned "The directory MyApp/bin/wrapper contains 2 files".

Could you check your script for instance where you're using the name of the directory as a command? Such as using wrapper (which is the directory name) instead of wrapper/wrapper-linux-x86-32 (which would be a file name), or similar errors?

Similar errors often appear when using spaces in filenames and forgetting to quote said filenames (probably not the case here, though.)

Failing that, could you edit your question to include the contents of the wrapper script you're calling?

(New answer since it's completely unrelated to the previous noexec idea, and that one can stay for reference.)

于 2009-04-07T23:37:28.030 回答
0

您可能还必须向包装器授予执行脚本

chmod +x 包装器.sh

编辑:我刚刚注意到您的 wrapper.sh 位于您的 MyApp 文件夹 /EDIT

另外,如果你确定你有

#!/bin/sh

在 .sh 文件的顶部,您可以像这样执行它:

.wrapper.sh

于 2009-04-07T23:17:18.343 回答
0

首先,尝试在文本编辑器中打开它,以确保您具有读取权限。如果是这样,做

chmod +x wrapper.sh

并确保你#!/bin/sh在脚本的开头

于 2009-04-07T23:18:40.163 回答
0

You may try to execute the file that was there in other user's home directory, you can give permission to the user "user"

chmod -R a+x /home/user1 or chmod -R o+x /home/user1 chmod -R g+x /home/user1

于 2009-04-22T04:39:02.760 回答
0

Although my problem was a bit different this question appeared in my search few times while searching for similar problem so I'll post my findings here.

My problem was that I couldn't access storage/ folder after chmod command.

After executing command:

sudo chmod -755 storage -R    //notice -755 is wrong, it should be 755

I couldn't access storage/ folder any more.

I've tried ls -l:

storage permissions d---------

Also after git status:

storage/.gitignore: Permission denied

After executing the right command:

sudo chmod 755 storage -R // without -

everything returned back to normal.

于 2017-04-04T09:57:32.990 回答