Search code examples
c++pythonwindowscygwin

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

Solution

  • 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"')