X-Recipient: archive-cygwin@delorie.com
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 54BAF3858428
Authentication-Results: sourceware.org;
 dmarc=none (p=none dis=none) header.from=cs.umass.edu
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.umass.edu
Message-ID: <251df5f2-56b8-0812-c990-a517bd686ec5@cs.umass.edu>
Date: Wed, 31 Aug 2022 14:39:59 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
 Thunderbird/102.2.0
Subject: Re: Running cygwin from python
Content-Language: en-US
To: Toyoshima Denis <denis.toyoshima@volvo.com>,
        "cygwin@cygwin.com" <cygwin@cygwin.com>
References: <DB7PR05MB4252EB21D222A73D2AC7B6E9F1789@DB7PR05MB4252.eurprd05.prod.outlook.com>
From: Eliot Moss <moss@cs.umass.edu>
In-Reply-To: <DB7PR05MB4252EB21D222A73D2AC7B6E9F1789@DB7PR05MB4252.eurprd05.prod.outlook.com>
X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL,
 KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP,
 T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
Reply-To: moss@cs.umass.edu
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 27VIf227028574

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

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

