Cygwin 自动脚本启动

发布于 2024-10-18 22:47:39 字数 192 浏览 4 评论 0原文

我试图通过 CMD 使用 Cygwin 自动运行脚本。我基本上创建了一个 BAT 文件,该文件转到该目录并执行 .SH 文件。 SH 文件与 Cygwin 相关,我在命令行中尝试了类似“cygwin update.sh”的内容。但它真正做的只是打开 Cygwin。我希望 Cygwin 自动运行脚本文件。有没有简单的方法可以做到这一点,我一直在努力寻找但找不到。谢谢你!

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 want 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烛影斜 2024-10-25 22:47:39

您需要使用特定的 shell(例如 bash)调用 shell 脚本。

打开 Cygwin 时,调用 which bash 来找出二进制文件的位置。 Cygwin 还附带了可以在 Cygwin 和 Win32 形式之间转换路径的工具,这对于像您这样的情况非常有用。

还有一件事可能会起作用,具体取决于您的设置。有一个名为 PATHEXT 的环境变量,它声明 CMD 认为“可执行”的文件扩展名。如果 Windows 配置为使 shell 的“打开”动词执行文件扩展名 .sh 的正确 shell(在您的情况下),这可以为您带来好处。

祝你好运。

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.

十秒萌定你 2024-10-25 22:47:39

从 Cygwin 终端,阅读 man mintty。从 Windows 命令提示符中尝试执行以下操作:

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

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
堇年纸鸢 2024-10-25 22:47:39

我也发现了这个!

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

一开始我不太明白,但后来它就按照我想要的方式工作了。如果有人知道,有没有办法让脚本在不打开 CMD 窗口的情况下运行?谢谢

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文