Python without a tty
hansmu at xs4all.nl
Thu Sep 29 13:50:29 CEST 2011
On 29/09/11 12:52:22, Steven D'Aprano wrote:
> [steve at sylar ~]$ python -c "import sys,os; print os.isatty(sys.stdout.fileno())"
> If I run the same Python command (without the setsid) as a cron job, I
> get False emailed to me. That's the effect I'm looking for.
In that case, all you need to do is redirect stdout:
$ python -c "import sys, os
> print os.isatty(sys.stdout.fileno())" >/tmp/xxx
$ cat /tmp/xxx
You'll probably want to redirect to /dev/null and
maybe you want to redirect stdin and stderr as well.
More information about the Python-list