cygwin 上的 bash 脚本 - 似乎卡在连续命令之间。
我正在使用 bash 脚本通过 cygwin 在 Windows 计算机上运行多个应用程序(有些重复运行)。该脚本包含逐行启动这些应用程序的命令。这些应用程序中的大多数都会运行很多分钟,而且我多次观察到即使第 i 个应用程序完成后,第 i+1 个应用程序也没有启动。在这种情况下,如果我在运行 bash 脚本的 cygwin 控制台中按 enter,下一个应用程序就会开始运行。是因为 cygwin 上的 bash 有问题吗?还是Windows操作系统本身的问题?你们中有人在 bash + cygwin + Windows 中观察到过这样的问题吗?
谢谢。
I am using a bash script to run a number of application (some repeatedly) on a Windows machine through cygwin. The script contains commands to launch those applications, line by line. Most of these applications run for many minutes and many times I have observed that the i+1 th application is not being started even after i th application is completed. In such cases, if I press enter in the cygwin console on which the bash script is running, the next application starts running. Is it because of any issue with bash on cygwin? Or is it an issue with the Windows OS itself? Have any of you observed such an issue with bash + cygwin + Windows?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我想我以前见过这个。
或
尝试
如果这不起作用,请尝试
其他重定向,例如
I think I have seen this before.
Instead of
try
If that doesn't work, try
Or experiment with other redirections, e.g.
听起来你的 shell 脚本编码可能有问题; DOS(和 Windows)使用 CR+LF 行结尾,而 Linux 使用 LF 结尾。尝试将文件另存为 LF。
还可能发生的情况:
当我在学校笔记本电脑上运行 Cygwin 时,与在本机 Linux 环境中运行相比,我遇到了 shell 脚本急剧减慢的情况。当从 GNU Autotools 运行
configure
脚本时,这一点尤其明显。您可能还想检查是否正在运行防病毒程序。防病毒程序倾向于在执行时扫描每个可执行文件。即使简单的 shell 脚本在运行之前运行数百甚至数千个单独的程序,这也可能会导致问题。
此邮件列表帖子概述了伪安装所需的内容主 /usr/bin 目录为 cygexec。我不确定它的作用,但我发现它有帮助。
如果您正在运行
configure
脚本,请尝试-C
选项。希望这有帮助!
Sounds like you may have a problem with your shell script encoding; DOS (and Windows) uses CR+LF line endings, whereas Linux uses LF endings. Try saving the file as LF.
What might also be going on:
When I was running Cygwin on a school laptop, I encountered a dramatic slowing of shell scripts vs. when they were running in a native Linux environment. This was especially apparent when running a
configure
script from GNU Autotools.You might also want to check whether you have an antivirus program running. Antivirus programs tend to scan every single executable file as it is executed; this can cause problems for even simple shell scripts that run hundreds or even thousands of individual programs before they run their course.
This mailing list post outlines what is needed to pseudo-mount the main /usr/bin directory as
cygexec
. I'm not sure what that does, but I found it helped.If you're running a
configure
script, try the-C
option.Hope this helps!
有时,我会遇到这种行为,因为我不小心删除了脚本顶部的“she-bang”,即删除了脚本第一行的#!/bin/bash。
当父 shell 脚本调用缺少 she-bang 的子脚本时,更有可能发生这种情况!
希望这有帮助。
Occasionally, I'll get this behaviour because I have accidentally deleted the 'she-bang' at the top of the script, that is, deleted the #!/bin/bash on the first line of the script.
It's even more likely for this to happen when a parent shell script calls a child script that has the she-bang missing!
Hope this helps.
虽然可能性不大,但我之前也见过一些类似的行为。
在 Windows 2000 中,如果在命令提示符窗口中运行的任何程序的某些文本被光标突出显示,它将暂停命令运行,并且您必须按 Enter 或清除突出显示才能让命令提示符继续执行。
正如我所说,虽然可能性不大,但意外的鼠标点击可能是您的问题......
A bit of a long shot, but I have seen some similar behaviour previously.
In Windows 2000, if any program running in a command prompt window had some of it's text highlighted by the cursor, it would pause the command running, and you had to press enter or clear the highlighting to get the command prompt to continue executing.
As I said, bit of a long shot, but accidental mouse clicks could be your issue...
安装带有 unix 风格换行符的 cygwin,然后忘记类似的奇怪问题。
尝试将您的脚本保存为 cygwin 的“the-properly-line-broken-style”。即使用您在安装时指定的样式。
以下是一些相关信息:
https://stackoverflow.com/a/7048200/657703
Install cygwin with unix style line breaks and forget weird problems like that.
Try saving your script as "the-properly-line-broken-style" for your cygwin. That is, use the style you specified under installation.
Here is some relevant information:
https://stackoverflow.com/a/7048200/657703