简体   繁体   English

无法在Windows Cygwin中执行bash脚本

[英]Unable to execute bash script in windows cygwin

I am trying to execute bash script on windows using cygwin but getting error as commands not found 我正在尝试使用cygwin在Windows上执行bash脚本,但由于找不到命令而出现错误

sample : test.sh 示例:test.sh

#!/bin/bash ls

and I am executing it as C:\\Apps\\cygwin64\\bin\\bash.exe /cygdrive/g/Scripts/test.sh 并且我以C:\\Apps\\cygwin64\\bin\\bash.exe /cygdrive/g/Scripts/test.sh执行它

getting error as test.sh: line 2: ls: command not found 作为test.sh出现错误:第2行:ls:找不到命令

If you are running this from the Windows command prompt, or from a Windows batch file, in order for your PATH and other environment variables to be set correctly, you need to invoke the --login option. 如果从Windows命令提示符或Windows批处理文件运行此命令,则为了正确设置PATH和其他环境变量,需要调用--login选项。 Run your command as follows: 运行命令,如下所示:

 C:\Apps\cygwin64\bin\bash.exe --login -c "/cygdrive/g/Scripts/test.sh"

This should do the trick. 这应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM