[英]Java ProcessBuilder returns exit error 128 executing git in linux ( some git command working fine )
Simple git command i try to execute with java ProcessBuilder , working find when i run it in linux with results returned. 我尝试使用java ProcessBuilder执行简单的git命令,当我在linux中运行它并返回结果时可以正常工作。 this is the command : 这是命令:
git -C /home/mlxx log -1 "72xxxxxxxxe700d6bbe06" --pretty=format:"%s"
when i try to execute it in java 当我尝试在Java中执行它时
ProcessBuilder pb = new ProcessBuilder()
.command("git","-C","/home/mlxx","log","1","72xxxxxxxxe700d6bbe06","--pretty=format:\"%s\"").directory("/bin/bash");
The int exit = p.waitFor(); int出口= p.waitFor(); returns 128 error code 返回128个错误代码
now according to this link : Start GitLog with Java Process Builder which face the same problem 现在根据此链接: 使用Java Process Builder启动GitLog,它面临相同的问题
i tried to do : 我试图做:
ProcessBuilder pb = new ProcessBuilder()
.command("/usr/bin","-c""git","-C","/home/mlxx","log","1","72xxxxxxxxe700d6bbe06","--pretty=format:\"%s\"")
The int exit = p.waitFor(); int出口= p.waitFor(); returns 1 error c0de 返回1错误c0de
what is wrong here ? 这是怎么了?
other commands working just fine in linux via java? 其他命令通过Java在Linux中工作正常吗?
You are specifying /bin/bash
as the process's working directory: 您正在将/bin/bash
指定为进程的工作目录:
[...] .directory("/bin/bash");
This is an executable file and not a valid directory. 这是一个可执行文件,不是有效目录。
You can leave it off entirely, since you already specify the directory git
should operate on with its -C
option. 您可以完全关闭它,因为您已经指定了目录git
应该使用-C
选项进行操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.