Python Forum
running python script from shell invoked with os.system("x-terminal-emulator -e /bin/ - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: running python script from shell invoked with os.system("x-terminal-emulator -e /bin/ (/thread-16269.html)



running python script from shell invoked with os.system("x-terminal-emulator -e /bin/ - markhaus - Feb-20-2019

I have the following code in a file "hello.py":


#!/usr/bin/python3

import os

import time
os.system("x-terminal-emulator -e /bin/bash")

var = input("Please enter your name: ")
print("You entered " + str(var))
time.sleep(5)
os._exit(1)

I would like to run the script in the spawned terminal. I have searched google and the forums and have no answer. Any help would be appreciated.


RE: running python script from shell invoked with os.system("x-terminal-emulator -e /bin/ - Larz60+ - Feb-20-2019

Are you trying to create a virus?
doing what you suggest will quickly overload the OS.
Although it will be slowed down by the input statement.


RE: running python script from shell invoked with os.system("x-terminal-emulator -e /bin/ - markhaus - Feb-21-2019

no virus. Trying to open a terminal window, run the little script to capture the name, print that output, and then close the terminal. This works when I run it from a terminal:
it captures the input, prints it, and exits 5 seconds later no problem. I just can't do it from within this one file and I cannot figure out why. Thanks for responding. It's just a learning exercise and I'm having no luck.