嗨,我有以下方法,触发时应该在 Git Bash 中运行命令。
function convert($tmpName, $fileName, $fileSize, $fileType){
}
该命令将如下所示:
pyang -f yin -o H:''YangModels''yin''ietf-inet-types.yin ietf-inet-types.yang
我在这里查看 shell 命令,但不知道这是否与 Git Bash 有关。
只是在寻找一种在 PHP 方法运行时在 Git Bash 中运行命令的方法,谢谢。
该命令必须通过Git Bash运行,它将无法通过正常的命令行或Windows shell工作。
编辑:一直在研究它,并找到了一个可能与我需要的命令相似的命令。用户似乎试图通过 cygwin 运行他的命令,试图指定我的命令以目标 git bash 但还没有弄清楚。
$result = shell_exec('C:/cygwin/bin/bash.exe /c --login -i git');
exec 或 shell_exec 可以运行您通常通过命令行运行的任何命令,例如
shell_exec('cd /var/www && /path/to/git pull origin master');
我不确定您的代码是如何形成的,但它可能是这样的:
function convert($tmpName, $fileName, $fileSize, $fileType){
$output = shell_exec('pyang -f '.$fileType.' -o '.$tmpName.' '.$fileName);
}