【问题标题】:bash -c from bat file spawned from exe not a commandbash -c 来自从 exe 生成的 bat 文件,而不是命令
【发布时间】:2016-09-29 14:16:13
【问题描述】:

当我作为 exe (pidgin) 的子进程运行 bash -c(Windows 上 ubuntu 上 linux/Bash 的 windows 子系统的一部分)的批处理文件时,即使该 exe 在 Windows 中被提升/管理员批处理文件错误:

'bash' is not recognized as an internal or external command,
operable program or batch file.

我正在运行的 .bat 文件是:

bash -c "curl --silent -u '''my api key'':' -d type='note' -d body='My Message' -d title='My Subject' 'https://api.pushbullet.com/v2/pushes'"
pause #disable after debugging

我打算将它作为 pidgin 中的“伙伴突袭”,这样当我收到来自 Nickserv 的消息时,它会在任何地方通知我。

我也尝试直接从 pidgin 执行命令,而不是作为 bash 文件运行,但是 curl 从未发生过,而且我没有通过 pushbullet 收到通知。但是,如果我在 CMD 或 Run 中运行完全相同的命令,它将使用 bash 并成功执行 curl。

我也发现了这个问题:Calling Windows subsystem for Linux apps through PowerShell/cmd,但我不确定它是否回答了这无法完成,因为您显然可以将 bash 命令放入 bat 文件中。

【问题讨论】:

    标签: windows bash batch-file windows-subsystem-for-linux


    【解决方案1】:

    您是否尝试过在批处理文件中完全指定 bash shell 的路径?

    如果您将 curl.bat 文件中的 bash 命令替换为 c:\Windows\System32\bash.exe,事情可能会更好一些。似乎 pidgin 没有可用于它产生的进程的完整路径环境变量。

    【讨论】:

    • 哇,这是一个很好的建议,但遗憾的是它不起作用。我已经放弃了这个想法,但是尝试并测试 WSL 的限制很有趣
    • 如果有人真的想像这样卷曲,我建议只安装一个 windows 的 curl 并从那里运行
    【解决方案2】:

    将路径更改为 C:\Windows\sysnative\bash.exe。 Pidgin 是 32 位的,因此它将 C:\Windows\System32 别名为 C:\Windows\SysWOW64,将 C:\Windows\sysnative 别名为 C:\Windows\System32。 MS 将 SysWOW64 中的 bash.exe 符号链接到真实的可能是有意义的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-19
      • 1970-01-01
      • 2015-07-15
      • 1970-01-01
      • 1970-01-01
      • 2011-09-18
      相关资源
      最近更新 更多