[mythtv-users] Ways to Query Database From sh Script?

Nick Rout nick.rout at gmail.com
Mon Feb 16 01:40:07 UTC 2009


On Mon, Feb 16, 2009 at 12:51 PM, Drew Tomlinson
<drew at mykitchentable.net> wrote:
> I'm working on my first UserJob script.  In this script, I want to test
> if a recording has a cutlist before processing.  I've Googled and the
> way found to query the database from /bin/sh goes like this:
>
> CUTLIST=`cat << EOF | mysql -u mythtv -pmythtv mythconverg
>        SELECT
>                cutlist
>        FROM
>                recorded
>        WHERE
>                basename = '$FILENAME';
> EOF`
>
> Using the above, $CUTLIST will be set to either "cutlist 1" or "cutlist
> 0" depending upon whether a cutlist exists. (I suppose piping to awk
> would remove "cutlist").  Is this the only way to query from /bin/sh?
> Is there a more practical way?
>
> I'm pretty new to this stuff so if the answer is obvious, nudges to the
> relevant links would be appreciated.
>
> Thanks,
>
> Drew

What you are doing is essentially correct, but may be able to be
factored better.

But you probably would be much better off with python or perl and the
respective mythtv bindings :)


More information about the mythtv-users mailing list