开发者

Cygwin automatic script launch

开发者 https://www.devze.com 2023-02-13 14:33 出处:网络
Im trying to automatically run a script using Cygwin via CMD.I basically created a BAT file that goes to the directory and executes an .SH file.SH files are accosiated with Cygwin, and I tried somethi

Im trying to automatically run a script using Cygwin via CMD. I basically created a BAT file that goes to the directory and executes an .SH file. SH files are accosiated with Cygwin, and I tried something like "cygwin update.sh" in the command line. But all it really does is open Cygwin. I wan开发者_如何学JAVAt Cygwin to automatically run the script file. Is there any easy way to do this, I've been trying to find but can't. Thank you!


You'll want to call the shell script with a particular shell, e.g. bash.

When having Cygwin open, call which bash to figure out where the binary is located. Cygwin also comes with tools that can convert paths between Cygwin and Win32 form, which is pretty helpful in cases like yours.

There is one other thing that may work, depending on your setup. There is an environment variable named PATHEXT which declares file extensions that are deemed "executable" by CMD. This can be used to your advantage, if Windows is configured so that the shell's "open" verb executes the correct shell for the file extension .sh (in your case).

Good luck.


From Cygwin Terminal, read man mintty. Try something like the following from a Windows Command Prompt:

c:\cygwin\bin\mintty --hold always --exec /cygdrive/c/path/to/bash/script.sh


I also found this!

http://rothmanshore.com/2011/01/26/kick-off-a-cygwin-script-from-a-windows-bat-file-with-a-different-working-directory/

I didn't quite understand it at first, but then it worked as I wanted it. Just if anyone knows, is there a way to make the script run without the CMD window open?? Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号