I'm creating a python script (cmd_exec.py
) to open another python script (entername.py
). How do I nest it so the script inputs string and execute the enter button all automatically? Trying to remember the question about ASCII input code for enter, but can't find it. So that when I run the cmd_exec.py
in powershell, it would display "Hello foo"
:
cmd_exec.py:
import subprocess, sys
p = subprocess.Popen(["powershell.exe", "py C:\\Users\\uname\\PProjects\\cmdauto\\entername.py"], stdout=sys.stdout)
p.communicate()
I want maname
variable to get inserted in the entername.py
script and the script to execute/press enter button. So that when I run the cmd_exec.py
script, I would see it doing all by itself and prints out "Hello foo"
entername.py:
maname = "foo"
person = input('Enter your name: ')
print('Hello', person)