Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute shell script on cygwin from Python

I want to execute a shell script, on cygwin from Python. The shell script is creating a file as an output.

I tried

import os
import subprocess

os.chdir(r"C:\\cygwin64\\bin\\ ")
cmd = ["bash", "-c", 'cd /<path for the script>; ./test.sh']
subprocess.call(cmd)
like image 333
Michael Avatar asked Apr 18 '26 19:04

Michael


1 Answers

This works:

import os, subprocess
os.chdir(r"C:\cygwin64\bin")
cmd = ["bash", "-c", "cd $HOME; pwd; exit"]
ret = subprocess.call(cmd)
like image 105
Alba Avatar answered Apr 21 '26 00:04

Alba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!