Home > database >  I am executing os.system ("unit run" directoryPath " urun shell"), which opens
I am executing os.system ("unit run" directoryPath " urun shell"), which opens

Time:12-15

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 below 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

CodePudding user response:

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

CodePudding user response:

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"'
  • Related