run .sh file from python spyder in windows

Multi tool use
run .sh file from python spyder in windows
Please help me to run .sh
file (bash file) from Python Spyder IDE in windows. I am using the below code.
.sh
import subprocess
subprocess.call(['./test.sh'])
I am facing the error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
I do not know where I have to keep test.sh
file in windows.
test.sh
How about just rewriting the shell script into Python?
– cricket_007
Jul 2 at 5:43
1 Answer
1
change dir
while calling the test.sh
file :
change dir
test.sh
First, install Git (https://git-scm.com/downloads)
>>> import os
>>> from subprocess import Popen,PIPE
>>> os.chdir("path of test.sh file")
>>> p = Popen(["filename"], shell=True, stdout = PIPE)
There is some security consideration plz read this:
(Using subprocess.Popen to run a batch file in Windows)
and read comment session also
Thanks for your reply.I did the same but it is not working for me.Have you tried to do the same in windows?
– ankit jain
Jul 2 at 4:20
Ya it worked for me
– Hitesh_Gorana
Jul 2 at 4:45
Now I am getting error: OSError: [WinError 193] %1 is not a valid Win32 application
– ankit jain
Jul 2 at 5:04
i am editing my answer
– Hitesh_Gorana
Jul 2 at 5:31
you should have` git bash` installed
– Hitesh_Gorana
Jul 2 at 5:38
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I'm not sure there is going to be any easy way to run a shell script file on Windows (from Python or otherwise), since you probably don't have a Unix shell program available to run it.
– Blckknght
Jul 1 at 17:18