0

I am running a command os.system("unit run" + directoryPath + " urun shell"), which opens the shell prompt of the unit. How should I run commands on the shell prompt that is a whole new prompt getting open up with Python?

I tried executing the command os.system("unit run" + directoryPath + " urun shell /c command"), but that didn't worked as I was expecting that the command should have ran on the shell prompt.

wovano
  • 4,543
  • 5
  • 22
  • 49

2 Answers2

0

As far as I know you can just call os.system() again with your shell-command.

smyril
  • 111
  • 10
0

Use the subprocess module:

import subprocess

subprocess.run(["unit", "run", directoryPath, "urun" "shell"], shell=True, check=True)

Note you may need to include escaped quote marks in the directoryPath value:

directoryPath = '"some directory path"'
Bill Horvath
  • 1,336
  • 9
  • 24