gpt4 book ai didi

windows - 从 Cygwin 批量获取命令结果

转载 作者:可可西里 更新时间:2023-11-01 09:24:45 26 4
gpt4 key购买 nike

问题

我对 Cygwin 有点陌生,我正在尝试从 Batch 在 Cygwin 中运行一个 shell 脚本并获取返回值。我一直在搜索,我尝试使用 C:\cygwin[64]\bin\bash[64].exe 甚至搞乱了 C:\cygwin[64]\Cygwin .bat 但无济于事。

基本上,我只是希望能够从批处理中与 bash(来自 Cygwin)进行交互。如果这对您来说似乎微不足道,请原谅,因为我是 Cygwin 的新手。无论如何,我还没有找到有效的在线解决方案。

Sudo 代码示例:

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

我试过的一些东西

我通过长时间的 Google 搜索找到了所有这些东西。什么也没做我想要的。

"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 交互。我已经用第三种语言计划了我的解决方案,但它只是无法正常工作的 batch-to-cygwin。

注意事项

  • Windows 7 家庭高级版 x64
  • Cygwin x64
  • 我在代码中将所有 64 写为 [64] 因为我知道 32 位版本不使用它。
  • 如果我遗漏了什么或我的问题有点不对(太宽泛、太具体等),请发表评论,我会进行更改。

最佳答案

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

关于windows - 从 Cygwin 批量获取命令结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21212267/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com