Reputation: 1439
I'm making a Python script that automates some tasks in Linux. The script installs some packages and, after the installation of this pacakges, i want the user to run some terminal commands. I was wondering if there is a way for do this by "Pausing" the script and by creating a direct comunication between the terminal and the user.
I know that there are other ways for do that like by writing an input statement in python and make an os
call that run what the user typed like this
from python import os
cmd = input('Type your command here: ')
os.system(cmd)
or by using some subrocess
functions in the same way
import subprocess
cmd = input('Type your command here: ')
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output, errors = p.communicate()
But there is a way for create a comunication between the terminal and the user while the script is running without the necessity to open a new terminal?
Upvotes: 0
Views: 83