I need to create a script in Phyton that when run either by mouse click or 'enter' the keyboard, it opens the Linux terminal itself and executes any command inside it. I've already been able to get it to run the command, but as long as the script runs inside the terminal.
I have tried everything I was able to do with google, I tried to use os.system (), subprocess (), but none solved. My code at the moment is the following:
#!/usr/bin/env python3
# -*- coding; utf-8 -*-
import subprocess
processo = subprocess.Popen(args = ['pantheon-terminal'],
stdin = subprocess.PIPE,
stderr = subprocess.PIPE,
shell = True)
processo.communicate('ls') # Aqui um erro
It should open the terminal and run the ls command, but only open the terminal.
Edit: As you can see above, I was using process.communicate ('ls'), ie I was passing the command wrongly, but I still do not know where to put the command for it to run inside the terminal that was opened by the script. / p>