I have a python script that I run by passing some arguments as environment variables:

param=1 length=5 python myscript.py

I want to run it inside a screen. I tried screen -m param=1 length=5 python myscript.py but this does not work, I get the error "Cannot exec param=1, no such file or directory". How can I still run this script within a screen?

  • 2
    Can't you use something like screen -m bash -c 'param=1 length=5 python myscript.py'? – pfnuesel Aug 7 '17 at 23:24


param=1 length=5 screen -m python myscript.py


$ cat myscript.py
import os
print(os.environ["param"], os.environ["length"])

If we run this command:

$ param=1 length=5 screen -m python myscript.py

The output appears:

('1', '5')

(For python3, replace raw_input with input. Also, note that the output will display slightly differently.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.