Python Forum
executing a bash file - revisited
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
executing a bash file - revisited
#2
First I assume that you have started your program with
import subprocess as sub
If not, the code makes no sense.

Even so, you try to invoke a shellscript, but that is not the intended use for subprocess. It is meant to start a process and one of the arguments may be a file. Your call makes subprocess try to interpret the argument as a file named "sh /home/pi/MagicMirror/restartMM.sh". If you take away "sh " it will complain about file permissions unless you have made it executable. Another way is:
import os
p = os.system("sh /home/pi/MagicMirror/restartMM.sh")
print(p)
Reply


Messages In This Thread
executing a bash file - revisited - by ebolisa - Feb-09-2021, 08:56 PM
RE: executing a bash file - revisited - by Serafim - Feb-09-2021, 10:28 PM
RE: executing a bash file - revisited - by ebolisa - Feb-10-2021, 11:06 AM
RE: executing a bash file - revisited - by ebolisa - Feb-10-2021, 04:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Function not executing each file in folder mathew_31 9 2,352 Aug-22-2022, 08:40 PM
Last Post: deanhystad
  Showing and saving the output of a python file run through bash Rim 3 2,534 Oct-06-2021, 10:48 AM
Last Post: gerpark
  file.write stops while true loop from executing in python3 boonr 3 3,159 Mar-25-2019, 12:50 PM
Last Post: ichabod801
  Executing external Python file in background and get output in python nakiscia 0 4,993 Feb-15-2018, 02:07 PM
Last Post: nakiscia
  executing a file saved in memory Skaperen 0 2,406 Sep-04-2017, 04:23 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020