Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run bash command in Cygwin from another application

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

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

@echo off

C:
chdir C:\cygwin\bin

bash --login -i
like image 845
G-71 Avatar asked Jul 18 '26 00:07

G-71


1 Answers

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"')
like image 189
Marcelo Cantos Avatar answered Jul 20 '26 13:07

Marcelo Cantos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!