从另一个应用程序在Cygwin中运行bash命令

G-7*_*-71 3 c++ python windows cygwin

从用C++或python编写的Windows应用程序,我如何执行任意shell命令?

我的Cygwin安装通常是从以下bat文件启动的:

@echo off

C:
chdir C:\cygwin\bin

bash --login -i
Run Code Online (Sandbox Code Playgroud)

Mar*_*tos 5

从Python,运行bash with os.system,os.popensubprocess传递适当的命令行参数.

os.system(r'C:\cygwin\bin\bash --login -c "some bash commands"')
Run Code Online (Sandbox Code Playgroud)