问题描述
我有一个可执行文件 (ffmpeg),我试图在 Mac 上使用 Java 程序运行它.我使用Java程序发送命令chmod 777/path/to/ffmpeg
,但是当我尝试运行ffmpeg时,出现以下错误:
I have an executable file (ffmpeg) that I'm trying to run with a Java program on a Mac. I used the Java program to send the command chmod 777 /path/to/ffmpeg
, but when I try to run ffmpeg, I get the following error:
java.io.IOException: Cannot run program "/Users/james/WalkTheHall/ffmpeg": error=13, Permission denied
但是当我在打开 Java 应用程序之前自己从终端运行 chmod 777/path/to/ffmpeg
时,ffmpeg 的命令将在 Java 程序中正常运行.
But when I run chmod 777 /path/to/ffmpeg
from Terminal on my own before opening the Java application, the command to ffmpeg will run just fine in the Java program.
在 Java 程序中调用 chmod
和我自己调用它有区别吗?为什么它不起作用?谢谢!
Is there a difference between calling chmod
from within the Java program and calling it on my own? Why will it not work? Thank you!
推荐答案
我猜 chmod
是一个 shell 命令,而不是一个可执行文件.尝试通过 shell 运行 chmod
.在此处查看更多详细信息:想要从 Java 调用 linux shell 命令
I'd guess that chmod
is a shell command, not an executable. Try running chmod
through your shell. See more details here: Want to invoke a linux shell command from Java
这篇关于Java 中 chmod 命令的权限被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!