Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.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
Php shell_exec()未使用Git Bash返回正确的结果_Php_Git_Shell - Fatal编程技术网

Php shell_exec()未使用Git Bash返回正确的结果

Php shell_exec()未使用Git Bash返回正确的结果,php,git,shell,Php,Git,Shell,我正在尝试使用shell_exec()通过PHP执行Git Bash。我试图插入的命令是shell\u exec(''C:\Program Files(x86)\Git\bin\sh.exe“-C”br-algorithm AgeEstimation \-enroll C:/Users/Username/S354-01-t10\u 01.jpg C:/Users/Username/S001-01-t10\u 01.jpg metadata.csv')。这将返回无法识别的函数-算法 这不会将正确的

我正在尝试使用shell_exec()通过PHP
执行Git Bash。我试图插入的命令是
shell\u exec(''C:\Program Files(x86)\Git\bin\sh.exe“-C”br-algorithm AgeEstimation \-enroll C:/Users/Username/S354-01-t10\u 01.jpg C:/Users/Username/S001-01-t10\u 01.jpg metadata.csv')
。这将返回
无法识别的函数-算法

这不会将正确的结果返回到PHP,但如果我只使用
shell_exec(''C:\Program Files(x86)\Git\bin\sh.exe“-C”br-help“)
,它将返回一个包含核心、杂项和其他命令(用于库)的页面


请使用shell_exec需要帮助。

我找到了问题的解决方案。为了使用
shell\u exec('some commmand')
,我必须在执行
shell\u exec()
之前指定打开shell的目录。这是通过使用PHP的
chdir('C:\users\userFolder')
实现的。这为我提供了正确的结果,我希望其他人觉得这有帮助

您能给jpg和csv文件提供绝对路径吗。@web nomad我用绝对路径编辑了我的问题。什么是命令
br
?从外观上看,它试图运行如下命令:
br-algorithm-AgeEstimation-enroll C
。。。。。所以错误是br说没有-algorithm@JoshfromQaribou,我对Git Bash非常陌生,在Git Bash中使用该行返回正确的结果,关于如何通过php返回正确结果的任何解决方案(即通过php执行Git Bash并使用
br-algorithm AgeEstimation…
作为某种参数?)?