[Tutor] interactif or not
work at infomaniak.ch
Tue Jun 7 14:00:43 CEST 2005
> If you want to know if your program has been launched from an interactive
> terminal or from a system background process like cron or init, then you
> look to see if stdin is a tty. Unix is usually very careful about who has a
> "controlling tty" and who does not. In Python, file objects have an isatty()
> method that will return True or False.
> import sys
> isinteractive = sys.stdin.isatty()
> if isinteractive:
tested and it works !
More information about the Tutor