简体   繁体   English

从exe生成的bat文件中的bash -c不是命令

[英]bash -c from bat file spawned from exe not a command

When I run a batch file that runs bash -c (part of windows subsystem for linux/Bash on ubuntu on windows) as a child process of an exe (pidgin), even if the exe is elevated/administrator in Windows the batch file errors: 当我运行一个运行bash -c (Windows子系统的一部分,在Windows上ubuntu上为Linux / Bash的Windows子系统)的批处理文件作为exe(pidgin)的子进程时,即使该exe在Windows中是提升权限/管理员,该批处理文件也会出现错误:

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

The .bat file that I am running is: 我正在运行的.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

What I intend to do is have it as a 'buddy pounce' in pidgin so that when I get a message from Nickserv, it will notify me everywhere. 我打算做的是将其作为pidgin中的“伙伴突袭”,以便当我收到Nickserv的消息时,它将在任何地方通知我。

I also tried to execute the command from pidgin directly rather than running as a bash file, but the curl never happens, and I don't get a notification through pushbullet. 我也尝试直接从pidgin执行命令,而不是作为bash文件运行,但是卷曲从未发生,并且我没有通过pushbullet收到通知。 But if I run the exact same command in CMD or in Run, it will use bash and execute the curl successfully. 但是,如果我在CMD或“运行”中运行完全相同的命令,它将使用bash并成功执行curl。 好友突袭配置的pidgin ui

I also found this question: Calling Windows subsystem for Linux apps through PowerShell/cmd but I'm not sure if it answers that this cannot be done because you clearly can put a bash command in a bat file. 我还发现了这个问题: 通过PowerShell / cmd调用Linux应用程序的Windows子系统,但是我不确定它是否能解决这个问题,因为您可以将bash命令放在bat文件中。

Have you tried fully specifying the path to the bash shell in your batch file? 您是否尝试在批处理文件中完全指定bash shell的路径?

If you replace the bash command in your curl.bat file with c:\\Windows\\System32\\bash.exe things may work a little better. 如果用c:\\ Windows \\ System32 \\ bash.exe替换curl.bat文件中的bash命令,则效果可能会更好一些。 Seems like pidgin doesn't have your full path environment variable available to the process it spawns. 好像pidgin对其生成的进程没有可用的完整路径环境变量。

Change the path to C:\\Windows\\sysnative\\bash.exe. 将路径更改为C:\\ Windows \\ sysnative \\ bash.exe。 Pidgin is 32-bit so it aliases C:\\Windows\\System32 to C:\\Windows\\SysWOW64 and C:\\Windows\\sysnative to C:\\Windows\\System32. Pidgin是32位的,因此将C:\\ Windows \\ System32别名为C:\\ Windows \\ SysWOW64,将C:\\ Windows \\ sysnative别名为C:\\ Windows \\ System32。 It would probably make sense for MS to symlink a bash.exe in SysWOW64 to the real one. MS将SysWOW64中的bash.exe符号链接到实际的符号链接可能很有意义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM