我正在编写一个将命令发送到 unix shell 的应用程序。
我在发出 cp 和 chmod 命令(我知道)方面从来没有遇到过任何麻烦,但由于某种原因,mv 命令实际上不会移动我加速的文件?
我的代码可以显示如下:
import java.io.IOException;
public class ExecuteCommand {
public static void main(String[] args){
ExecuteCommand exec = new ExecuteCommand("cp /some/directory/file.txt /some/directory/of/mine/");
ExecuteCommand exec2 = new ExecuteCommand("chmod 666 /some/directory/of/mine/file.txt");
ExecuteCommand exec3 = new ExecuteCommand("mv /some/directory/of/mine/file.txt /some/directory/of/mine/subDirectory/");
}
public ExecuteCommand(String command) {
try {
System.out.println("EXECUTING!::" + command);
Process child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
}
}
}
我尝试在命令之间放置计时器,但没有取得任何进展,以确保处理了 %100 的命令。
请注意,我的代码包含示例信息,如果某些 unix 文件系统语法不正确,请原谅我,请不要将问题归咎于此。
如果您需要任何进一步的信息,请询问,我会尽快提供
谢谢各位=)