I need to create a Python script to open a terminal window in Mac/Linux and need to execute the following commands in terminal from Python script.
- Open terminal
- Execute the command sudo openpyn --init""
- It will prompt for us to enter password and user name - Pass it from Python script
Tried with below but it is not working,Any idea or recommendations please.Will be of great help.
from openpyn import openpyn
import subprocess
import os
subprocess.call(["sudo openpyn --init"], shell=True)
os.system("sudo openpyn --init")
But it is not giving any results or not working as expected.
sudoreads a password from /dev/tty because a password has no reason to come from another program...os.system("""osascript -e 'tell application "Terminal" to do script "echo hello"'""")lswithout a Terminal.