How can i run install.sh file using python code.Purpose is to implement software update functionality.The sh file is generated using makeself and it is a self-extractable archive.Thanks in advance
CodePudding user response:
subprocess.call
(Python <=3.5) and subprocess.run
(Python >3.5) would be a safer alternative to os.system
.
CodePudding user response:
Solution 1 : Use SubProcess
import subprocess
subprocess.call(['/path/to/your/script.sh', 'argument1', 'argument2', ..., 'argumentn'])
Solution 2 : Use Os
import os
os.system('/path/to/your/script.sh argument1 argument2 ... argumentn'])
Both will work fine, if you have the choice it's better to use subprocess since it will handle for you the formatting of your command with thing such as space in the command line or special characters.