Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.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
Bash 在mintty中运行.bat文件_Bash_Git_Batch File_Git Bash_Mintty - Fatal编程技术网

Bash 在mintty中运行.bat文件

Bash 在mintty中运行.bat文件,bash,git,batch-file,git-bash,mintty,Bash,Git,Batch File,Git Bash,Mintty,我得到了一个.bat文件,需要执行一些脚本。我有用于Windows的Git bash mintty控制台,并希望从那里运行它。从普通的Windows控制台,它可以正常工作,但在mintty中,我得到: $ script.bat bash: script.bat: command not found 如何执行此操作?cmd/c script.bat 或 cmd/c“$(cygpath-w”/full/path/to/script.bat”)” 请注意,MS和Cygwin中的路径具有不兼容的语法。

我得到了一个.bat文件,需要执行一些脚本。我有用于Windows的Git bash mintty控制台,并希望从那里运行它。从普通的Windows控制台,它可以正常工作,但在mintty中,我得到:

$ script.bat
bash: script.bat: command not found

如何执行此操作?

cmd/c script.bat

cmd/c“$(cygpath-w”/full/path/to/script.bat”)”

请注意,MS和Cygwin中的路径具有不兼容的语法。因此,如果需要使用绝对路径或相对路径运行脚本,则需要相互转换

更新


在发布我的答案之后,我做了一些测试,创建批处理文件并直接在Cygwin/minty中运行它。无论是否使用
cmd/c
,它都能正常工作<代码>$COMSPEC已设置,Cygwin版本为1.7.25(不新鲜,但涵盖了我的许多作品)

您可能试图执行位于当前目录中的
script.bat
。Windows命令提示符首先搜索当前目录,找到脚本并执行它。Bash从不在当前目录中搜索可执行文件,它只在
$PATH
中声明的路径中查找这些文件

为了运行位于未在
$path
中指定的路径中的程序,在Bash中,必须使用包含斜杠(
/
)的路径来调用它。这意味着要从当前目录运行
.bat
脚本,您必须以以下方式调用它:

$ ./script.bat

您尚未向我们展示如何尝试运行批处理文件。你给我们的只是错误。没有产生预期的结果。