linux - Is it possible to include command line options in the python shebang? -


i have canonical shebang @ top of python scripts.

#!/usr/bin/env python 

however, still want export unbuffered output log file when run scripts, end calling:

$ python -u myscript.py &> myscript.out & 

can embed -u option in shebang so...

#!/usr/bin/env python -u 

and call:

$ ./myscript.py &> myscript.out & 

...to still unbuffering? suspect won't work, , want check before trying. there accomplish this?

you can have arguments on shebang line, operating systems have small limit on number of arguments. posix requires 1 argument supported, , common, including linux.

since you're using /usr/bin/env command, you're using 1 argument python, can't add argument -u. if want use python -u, you'll need hard-code absolute path python instead of using /usr/bin/env, e.g.

#!/usr/bin/python -u 

see related question: how use multiple arguments shebang (i.e. #!)?


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -