Running cygwin from python

Eliot Moss
Wed Aug 31 18:39:59 GMT 2022

On 8/31/2022 1:41 PM, Toyoshima Denis wrote:
> Hi there, how are you?
> I’d like to know if there’s any possibility of running simple commands inside Cygwin through Python code.
> If yes, could you provide some examples?

This will happen automatically if you use Cygwin's python.
If you don't, then you have to run a program (for example, ls)
by giving the path to the executable - on my system that is:


Any argument will need to be in a form that the Cygwin program
expects.  For example. to ls my Cygwin home directory, I could

C:\cygwin64\bin\ls.exe /home/moss

I could also do:

C:\cygwin64\bin\ls.exe /cygdrive/c/cygwin64/home/moss

You could also go through two steps, using the cygpath program to
convert paths to the desired form for a Cygwin program to obtain
a Cygwin form name to pass to a Cygwin program.

HTH - Eliot Moss

More information about the Cygwin mailing list