[mythtvnz] Problem running xmltv-proc-nz from user crontab

Steve Hodge stevehodge at gmail.com
Wed May 19 06:37:48 BST 2010


On Wed, May 19, 2010 at 4:47 PM, Robin Gilks <g8ecj at gilks.org> wrote:

> >
> > I have finally been able to spend some time debugging this problem,
> > and I have found out what is going wrong in xmltv-proc-nz when run
> > from a user cron job.  It is in this piece of code:
> >
> >     if sys.stdin.isatty():
> >         if len(args) == 0:
> >             log.critical('No input file')
> >             sys.exit(2)
> >         data = open(args[0]).read()
> >     else:
> >         data = sys.stdin.read()
> >
> > It appears that sys.stdin.isatty() returns false when run from my cron
> > job.  Which means that xmltv-proc-nz is not trying to read from the
> > file specified on the command line and is trying to get its data from
> > stdin.  So it gets no data, and then the XML parsing fails on an
> > immediate end of data.
> >
> > When I change my cron script from this:
> >
> >   /usr/local/bin/xmltv-proc-nz sky.xml >temp.xml
> >
> > to this:
> >
> >   cat sky.xml | /usr/local/bin/xmltv-proc-nz >temp.xml
> >
> > it works.
> >
> > Since my Python skills are sadly lacking and it works by piping the
> > data, I have not tried to fix xmltv-proc-nz.
>
> Looks to me as though the test is up-side-down. There will never be a tty
> when run from cron so it MUST have an input file on the command line. As
> it is it only looks for stdin input if its not run from a terminal.
>

I don't think so. It's easy to send stdin input to a program expecting a
filename. But if you're expecting a filename and some other program has
launched you and is trying to send stdin data there is nothing you can do
(more to the point, there's nothing the user can do to make it work). It is
tradition Unix behaviour to expect data to be passed via pipes rather than
temporary files in this situation.

Cheers,
Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ourshack.com/pipermail/mythtvnz/attachments/20100519/80ddcaf2/attachment.htm 


More information about the mythtvnz mailing list