0

Is it possible to send arguments to a Python3 background process?

$python3 message.py & # Linux: execute script in background

import time
s = 'foo'
terminal_msg = False # pseudocode
while True:
    if terminal_msg:  # pseudocode
        s = terminal_arg  # pseudocode
    print(s)
    time.sleep(5)
Jörg
  • 103
  • 4
  • This is a bit too vague. Conceptually, you have to write to a pipe from outside the program, and read it in the python code. The usual example is writing to its `stdin` from the terminal, and consuming it with `raw_input`. I guess that "running in the background" means you don't want to have an active terminal to handle it, in which case - redirect its input from a pipe and write to the pipe whenever you like. I can elaborate if needed. – NadavS May 02 '20 at 20:07
  • Does this answer your question? [How do you read from stdin?](https://stackoverflow.com/questions/1450393/how-do-you-read-from-stdin) – tink May 02 '20 at 20:34

0 Answers0