在批处理中从Cygwin获取命令的结果

问题

我对Cygwin有点新,我试图从批处理中运行Cygwin的shell脚本,并获得返回值。 我一直在四处search,我尝试使用C:\cygwin[64]\bin\bash[64].exe甚至与C:\cygwin[64]\Cygwin.bat但无济于事。

基本上,我只是希望能够从批处理,与bash(从Cygwin)进行交互。 请原谅,如果这对你来说似乎是微不足道的,因为我对Cygwin来说相当陌生。 无论如何,我还没有find一个在线工作的解决scheme。

示例Sudo代码:

 cygwin-magic "echo shell-command" #=> shell-command 

我试过的一些东西

我从长时间的Googlesearch中发现了所有这些东西。 没有做到我想要的。

 "C:\cygwin[64]\bin\base[64].exe" /cygdrive/c/users/<me>/desktop/tmp.sh #=> ZWNobyAiaGVsbG8i "C:\cygwin[64]\bin\base[64].exe" -d /cygdrive/c/users/<me>/desktop/tmp.sh #=> y▒h/usr/bin/base[64]: invalid input "C:\cygwin[64]\bin\base[64].exe" -d -i /cygdrive/c/users/<me>/desktop/tmp.sh #=> y▒h▒▒e/usr/bin/base[64]: invalid input "C:\cygwin[64]\bin\base[64].exe" -d -i "echo hello" #=> /usr/bin/base[64]: echo hello: No such file or directory # I kind of gave up on all of my other attempts and tried this because why not? Surprise surprise, it didn't work (not that I expected it to). "C:\cygwin[64]\Cygwin.bat" echo "hello" 

tmp.sh的内容

只是,

 echo "hello" 

目的

我想批量处理这个问题的原因是我想通过批处理(在Windows上)从另一种语言与bash进行交互。 我已经用第三种语言计划了我的解决scheme,但是这只是批处理到cygwin的工作。

笔记

  • Windows 7家庭高级版x64
  • Cygwin x64
  • 我在代码中编写了所有的64 [64]因为我知道32位构build不使用它。
  • 如果我错过了一些东西,或者我的问题有点偏离(太宽泛,太具体等),请发表评论,我会改变它。

也许你的意思是"C:\cygwin[64]\bin\basH[64].exe"不是"C:\cygwin[64]\bin\base[64].exe"