Running cygwin from python
Eliot Moss
moss@cs.umass.edu
Wed Aug 31 20:43:48 GMT 2022
On 8/31/2022 4:40 PM, René Berber wrote:
> On 8/31/2022 1:39 PM, Eliot Moss wrote:
>
>> 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:
>>
>> C:\cygwin64\bin\ls.exe
> [snip]
>
> I think he meant something like this:
>
> $ python
> Python 3.9.10 (main, Jan 20 2022, 21:37:52)
> [GCC 11.2.0] on cygwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import os
> >>> os.system("ls")
> ... output is a list of strings with the contents of current directory
> ^D
>
> Which is not a question for the Cygwin list, its elementary python.
... except if the OP is talking ab *Windows* python, in which case the
os package will run Windows things, not cygwin ones ...
Best - Eliot
More information about the Cygwin
mailing list