Mysterious EOFError
Steven D'Aprano
steve at REMOVETHIScyber.com.au
Sun Apr 9 03:09:21 EDT 2006
On Sat, 08 Apr 2006 23:07:54 -0700, Rex Eastbourne wrote:
> Hi,
>
> I'm executing a python script as a cron job. When I run it myself from
> the command line it works, but when cron executes it I get an EOFError:
>
> File "/home/rex/cronscript.py", line 6, in ?
> level = int(raw_input("hello?"))
> EOFError: EOF when reading a line
Because raw_input is waiting for input from the user. I assume that when
cron runs a Python script, and there is no actual human user to enter a
string in response to raw_input, it raises a EOF error.
Written in the docs:
http://docs.python.org/lib/module-exceptions.html
exception EOFError
Raised when one of the built-in functions (input() or raw_input())
hits an end-of-file condition (EOF) without reading any data. (N.B.:
the read() and readline() methods of file objects return an empty
string when they hit EOF.)
--
Steven.
More information about the Python-list
mailing list