D
D
ds_team12020-04-06 04:11:15
Python
ds_team1, 2020-04-06 04:11:15

How to run cmd as environment?

I 'm looking for a library capable of running a command line in a process without killing it
. Here's an example of what's needed:

venv = CMDENV()
venv.execute('cd /')
venv.execute('dir')
venv.close()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2020-04-06
@res2001

You need to run cmd in a normal process, redirecting cmd's stdin and stdout to pipes that you will control from python. See:

import os
import subprocess
help(subprocess.Popen)
help(os.pipe)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question