Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用java程序执行git dull命令时出现问题_Java_Git_Runtime - Fatal编程技术网

使用java程序执行git dull命令时出现问题

使用java程序执行git dull命令时出现问题,java,git,runtime,Java,Git,Runtime,我试图在windows上使用java程序在git命令下运行 git --git-dir D:\code_coverage\.git blame 'src/RunCodeCoverage.java' | grep e4ecfbe | awk '{print $7}' 这给了我一个错误: fatal: cannot stat path '$7}'': No such file or directory 在命令提示符下运行此命令时,它会根据需要提供结果 请帮忙 在Windows中的CMD上,

我试图在windows上使用java程序在git命令下运行

 git --git-dir D:\code_coverage\.git blame  'src/RunCodeCoverage.java'
 | grep e4ecfbe | awk '{print $7}'
这给了我一个错误:

fatal: cannot stat path '$7}'': No such file or directory
在命令提示符下运行此命令时,它会根据需要提供结果


请帮忙

在Windows中的CMD上,我可以对
awk
参数使用双引号使其工作:

 git --git-dir D:\code_coverage\.git blame  'src/RunCodeCoverage.java'
 | grep e4ecfbe | awk "{print $7}"
请注意,我的
awk.exe
来自

OP提到在Java中使用该命令时:

String commandToBeExecuted=“git--git dir D:\code_coverage\.git责备'src/RunCodeCoverage.java'| grep e4ecfbe | awk“{print$7}”;
进程p=Runtime.getRuntime().exec(commandToBeExecuted);
但您永远不会将所有参数作为单个字符串传递。
使用数组,如“”和“”中的

命令执行中的双引号转义为

 commandToBeExecuted = "git --git-dir D:\code_coverage\.git blame  'src/RunCodeCoverage.java'
 | grep e4ecfbe | awk \"{print $7}\""

感谢VonC,它可以通过CMD工作,但是当使用java运行时从java程序运行它时,它会给出提到的错误:致命:无法统计路径“$7}”:没有这样的文件或directory@ManishMankar您使用什么确切的Java代码将参数传递给Java
Runtime.exec()
命令?String commandToBeExecuted=“git--git dir D:\code_coverage\.git责怪'src/RunCodeCoverage.java'| grep e4ecfbe | awk“{print$7}”;进程p=Runtime.getRuntime().exec(commandToBeExecuted);@ManishMankar我已经修改了答案accordinglyThanks@VonC!但我还是有问题”致命:无法统计路径“src/RunCodeCoverage.java”:没有这样的文件或目录
 commandToBeExecuted = "git --git-dir D:\code_coverage\.git blame  'src/RunCodeCoverage.java'
 | grep e4ecfbe | awk \"{print $7}\""