Cannot pass an argument to python with #!/usr/bin/env python
It is better to use environment variable to enable this. See python doc : http://docs.python.org/2/using/cmdline.html
for your case:
export PYTHONUNBUFFERED=1
script.py
#! /usr/bin/env and process names: portability at a price?
"kill-ability" on the command line can by addressed portably and reliably using the PID of the backgrounded process obtained from shell $!
variable.
$ ./bintest.py & bg_pid=$! ; echo bg_pid=$bg_pid ; ps && kill $bg_pid
[1] 2993
bg_pid=2993
PID TTY TIME CMD
2410 pts/0 00:00:00 bash
2993 pts/0 00:00:00 bintest.py
2994 pts/0 00:00:00 ps
$
[1]+ Terminated ./bintest.py
$
and envtest.py
$ ./envtest.py & bg_pid=$! ; echo bg_pid=$bg_pid ; ps && kill $bg_pid
[1] 3016
bg_pid=3016
PID TTY TIME CMD
2410 pts/0 00:00:00 bash
3016 pts/0 00:00:00 python
3017 pts/0 00:00:00 ps
$
[1]+ Terminated ./envtest.py
$
As @Adam Bryzak points out, neither script cause the process title to be set on Mac OS X. So, if that feature is a firm requirement, you may need to install and use python module setproctitle with your application.
This Stackoverflow post discusses setting process title in python
Related Topics
Error Installing Geopandas:" a Gdal API Version Must Be Specified " in Anaconda
Fill Username and Password Using Selenium in Python
How to Set Folder Permissions in Windows
Group by & Count Function in SQLalchemy
Using Requests with Tls Doesn't Give Sni Support
How to Get the "Id" After Insert into MySQL Database with Python
How to List Pip Dependencies/Requirements
Python, Https Get with Basic Authentication
Django Rest Framework Upload Image: "The Submitted Data Was Not a File"
How to Remove Anaconda from Windows Completely
How to Handle a Broken Pipe (Sigpipe) in Python
Django Aggregation: Summation of Multiplication of Two Fields
Removing Unicode \U2026 Like Characters in a String in Python2.7
Pyqt4 Wait in Thread for User Input from Gui
Is There Any Simple Way to Benchmark Python Script
Using Moviepy, Scipy and Numpy in Amazon Lambda
How to Get All the Contiguous Substrings of a String in Python