向从批处理文件启动的窗口/进程发出命令
我想将命令传递给在批处理文件中启动的进程,特别是 Cygwin。 例如,如果我使用如下内容启动 Cygwin:
start "window1" cmd.exe /c cygwin
如何在启动 Cygwin 的同一个批处理文件中执行“window1”中的“ls”?
I want to pass commands to a process started in a batch file, specifically Cygwin. For instance, if I start Cygwin with something like the following:
start "window1" cmd.exe /c cygwin
How might I execute 'ls' in "window1", in the same batch file from which I started Cygwin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我必须问为什么要从批处理文件运行命令? 您想根据命令的结果/输出采取不同的操作吗?
无论哪种情况,您所要求的都是近乎不可能的。 为什么不简单地在 bash 脚本中编写逻辑并运行
start "window1" cmd.exe /cc:\cygwin\bin\bash.exe -c [script]
其中 [script] 是bash 脚本的路径。
有关 bash 脚本的文档可在 http://tldp.org/LDP/abs/html/
I have to ask why you want to run the commands from a batch file? Do you want to take different actions based on the results/output of the commands?
In either case, what you are asking is bordering on impossible. Why don't you simply write your logic in a bash script and run
start "window1" cmd.exe /c c:\cygwin\bin\bash.exe -c [script]
where [script] is the path of your bash script.
Documentation on bash scripting is available at http://tldp.org/LDP/abs/html/
如果您没有 cmd arg 到 cygwin 在启动时执行命令(例如 cmd.exe /K 或 /C),您可以使用一些脚本自动执行此类操作,例如 AutoHotKey。
If you don't have cmd arg to cygwin to execute command in startup (like cmd.exe /K or /C) you can automate such thing with some script like AutoHotKey.