0

Im trying to make a python program, and i just can't find any information on Google on how to just execute a non-python file from python (with an if statement). For Example:

if abc == "abc":
    "Execute ThisFile.sh"

EDIT: this was marked as dupe, but I am not trying to run a single command, I want to execute the entire file.

mas0701
  • 303
  • 2
  • 12

1 Answers1

3

Use subprocess module.

if abc == 'abc':
    subprocess.check_output('bash file.sh', shell=True)
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274