简体   繁体   中英

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

sample : test.sh

#!/bin/bash ls

and I am executing it as C:\\Apps\\cygwin64\\bin\\bash.exe /cygdrive/g/Scripts/test.sh

getting error as test.sh: line 2: ls: command not found

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. Run your command as follows:

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

This should do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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