Python script header

First, any time you run a script using the interpreter explicitly, as in the #! line is always ignored. The #! line is a Unix feature of executable scripts only, and you can see it documented in full on the man page for execve(2). There you will find that the word following #! must be the pathname of a valid executable. So executes whatever python is on … Read more

Meaning of $? (dollar question mark) in shell scripts

This is the exit status of the last executed command. For example the command true always returns a status of 0 and false always returns a status of 1: From the manual: (acessible by calling man bash in your shell) $?       Expands to the exit status of the most recently executed foreground pipeline. By convention an exit status of 0 means success, and non-zero return status … Read more

How can I sandbox Python in pure Python?

This is really non-trivial. There are two ways to sandbox Python. One is to create a restricted environment (i.e., very few globals etc.) and exec your code inside this environment. This is what Messa is suggesting. It’s nice but there are lots of ways to break out of the sandbox and create trouble. There was … Read more