public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Running cygwin from python
@ 2022-08-31 17:41 Toyoshima Denis
  2022-08-31 18:39 ` Eliot Moss
  0 siblings, 1 reply; 5+ messages in thread
From: Toyoshima Denis @ 2022-08-31 17:41 UTC (permalink / raw)
  To: cygwin

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?

Thanks in advance!

BR,

Denis

This email message (including its attachments) is confidential and may contain privileged information and is intended solely for the use of the individual and/or entity to whom it is addressed. If you are not the intended recipient of this e-mail you may not disseminate, distribute or copy this e-mail (including its attachments), or any part thereof. If this e-mail is received in error, please notify the sender immediately by return e-mail and make sure that this e-mail (including its attachments), and all copies thereof, are immediately deleted from your system. Please further note that when you communicate with us via email or visit our website we process your personal data. See our privacy policy for more information about how we process it: https://www.volvogroup.com/en-en/privacy.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Running cygwin from python
  2022-08-31 17:41 Running cygwin from python Toyoshima Denis
@ 2022-08-31 18:39 ` Eliot Moss
  2022-08-31 20:40   ` René Berber
  0 siblings, 1 reply; 5+ messages in thread
From: Eliot Moss @ 2022-08-31 18:39 UTC (permalink / raw)
  To: Toyoshima Denis, cygwin

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

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

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Running cygwin from python
  2022-08-31 18:39 ` Eliot Moss
@ 2022-08-31 20:40   ` René Berber
  2022-08-31 20:40     ` René Berber
  2022-08-31 20:43     ` Eliot Moss
  0 siblings, 2 replies; 5+ messages in thread
From: René Berber @ 2022-08-31 20:40 UTC (permalink / raw)
  To: cygwin

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.
-- 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Running cygwin from python
  2022-08-31 20:40   ` René Berber
@ 2022-08-31 20:40     ` René Berber
  2022-08-31 20:43     ` Eliot Moss
  1 sibling, 0 replies; 5+ messages in thread
From: René Berber @ 2022-08-31 20:40 UTC (permalink / raw)
  To: cygwin

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.
-- 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Running cygwin from python
  2022-08-31 20:40   ` René Berber
  2022-08-31 20:40     ` René Berber
@ 2022-08-31 20:43     ` Eliot Moss
  1 sibling, 0 replies; 5+ messages in thread
From: Eliot Moss @ 2022-08-31 20:43 UTC (permalink / raw)
  To: René Berber, cygwin

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-31 20:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31 17:41 Running cygwin from python Toyoshima Denis
2022-08-31 18:39 ` Eliot Moss
2022-08-31 20:40   ` René Berber
2022-08-31 20:40     ` René Berber
2022-08-31 20:43     ` Eliot Moss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).