Python Forum
running python script from shell invoked with os.system("x-terminal-emulator -e /bin/
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
running python script from shell invoked with os.system("x-terminal-emulator -e /bin/
#1
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.
Reply
#2
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.
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Running script from remote to server invisiblemind 4 737 Mar-28-2025, 07:57 AM
Last Post: buran
  Detect if another copy of a script is running from within the script gw1500se 4 1,129 Jan-31-2025, 11:30 PM
Last Post: Skaperen
  set -x shell equivalent of python, possible/available? ggpf900 1 470 Jan-25-2025, 08:01 PM
Last Post: Gribouillis
  updating pip, python - understanding terminal and pycharm. endlessnameless 0 1,165 Jun-24-2024, 05:48 AM
Last Post: endlessnameless
  No Internet connection when running a Python script basil_555 8 3,268 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 6,589 Mar-10-2024, 07:24 PM
Last Post: Winfried
  Help Running Python Script in Mac OS emojistickers 0 953 Nov-20-2023, 01:58 PM
Last Post: emojistickers
  Trying to make a board with turtle, nothing happens when running script Quascia 3 1,756 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  Help creating shell scrip for python file marciokoko 10 3,419 Sep-16-2023, 09:46 PM
Last Post: snippsat
  invoking python in Terminal Euler 2 1,266 Aug-25-2023, 06:17 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020