从另一个应用程序在Cygwin中运行bash命令 [英] Run bash command in Cygwin from another application

查看:277
本文介绍了从另一个应用程序在Cygwin中运行bash命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

From a windows application written on C++ or python, how can I execute arbitrary shell commands?

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

My installation of Cygwin is normally launched from the following bat file:

@echo off

C:
chdir C:\cygwin\bin

bash --login -i


推荐答案

从Python,使用 os.system os.popen / code>并传递相应的命令行参数。

From Python, run bash with os.system, os.popen or subprocess and pass the appropriate command-line arguments.

os.system(r'C:\cygwin\bin\bash --login -c "some bash commands"')

这篇关于从另一个应用程序在Cygwin中运行bash命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆