-1

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.I get this output when i use os.system or subprocess.run

Failed to parse arguments: Unknown option -title

NB: The Script file don't require any arguments

2 Answers2

0

subprocess.call (Python <=3.5) and subprocess.run (Python >3.5) would be a safer alternative to os.system.

Allan Wind
  • 23,068
  • 5
  • 28
  • 38
0

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.

Xiidref
  • 1,456
  • 8
  • 20