Abhishek Nagare
Abhishek Nagare

Reputation: 1

I am executing os.system ("unit run"+ directoryPath+" urun shell"), which opens the shell prompt of the unit, how to run commands on the shell promt?

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.

Upvotes: 0

Views: 33

Answers (2)

Bill Horvath
Bill Horvath

Reputation: 1717

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

Upvotes: 0

smyril
smyril

Reputation: 128

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

Upvotes: 0

Related Questions