[mythtv-users] Requeue All Shows Not Commflagged?

Drew Tomlinson drew at mykitchentable.net
Tue May 14 00:00:20 UTC 2013


On 5/13/2013 4:00 PM, Glenn Harris wrote:
> On Mon, May 13, 2013 at 11:33 AM, Drew Tomlinson 
> <drew at mykitchentable.net <mailto:drew at mykitchentable.net>> wrote:
>
>     After upgrading from 0.24 to 0.26, all my commflag jobs exited on
>     error 140.  After learning that it was because of the commflag
>     command and fixing that in the general setup, I wanted to commflag
>     all the recordings that had erred.  With some reading and
>     fiddling, I came up with this:
>
>     mysql mythconverg -umythtv -pmythtv < ~/commflag.sql | sed '1d;
>     s/-//g;s/://g' | awk '{print "/usr/bin/mythcommflag --queue
>     --chanid", $1, "--starttime",$2$3}'
>
>     Commflag.sql contains:
>     SELECT chanid, starttime FROM `mythconverg`.`recorded`where
>     commflagged <> 1;
>
>     Which prints this:
>
>     /usr/bin/mythcommflag --queue --chanid 2581 --starttime 20130513045900
>     /usr/bin/mythcommflag --queue --chanid 1278 --starttime 20130513045900
>     /usr/bin/mythcommflag --queue --chanid 3031 --starttime 20130509045900
>
>     So I added a 'for' loop with a 'do echo' to test:
>
>     for i in "`mysql mythconverg -umythtv -pmythtv < ~/commflag.sql |
>     sed '1d; s/-//g;s/://g' | awk '{print "/usr/bin/mythcommflag
>     --queue --chanid", $1, "--starttime",$2$3}'`"
>
>     do
>
>             echo ${i}
>
>     done
>
>
>     But the output is just one long line:
>
>     /usr/bin/mythcommflag --queue --chanid 2581 --starttime
>     20130513045900 /usr/bin/mythcommflag --queue --chanid 1278
>     --starttime 20130513045900 /usr/bin/mythcommflag --queue --chanid
>     3031 --starttime 20130509045900
>
>     I've read up on 'awk' and tried adding '\n' but this doesn't seem
>     to have any effect.  I've also read about $IFS and tried setting
>     that to '\n' but still no help.
>
>     Thus I have these questions:
>
>     1. Is a 'for' loop the proper loop to use?  I fiddled with 'while'
>     and 'read' and 'read line' but couldn't get those to work either.
>
>     2. How do I get the newline added so I can make this a script?
>
>     3. Am I duplicating something that already exists in MythTV?
>
>     Thanks for your time.
>
>     Cheers,
>
>     Drew
>
>
> I use something like this to get at mysql results in bash:
>
>
> current_line=0
> # read query results into $data, one line at a time
> mysql --user=$MYSQLUSER --password=$MYSQLPASSWORD $MYSQLDB < 
> myquery.sql | while read -r data
> do
>     current_line=$(($current_line+1))
>     IFS='       ' # tab as separator
>     line=(${data//NULL/0}) # replace NULL with a more useful value, 
> split $data into an array using IFS
>     unset IFS # back to default
>
>     # $line contains the current 'record' as an array
>     echo "$current_line -> ${line[0]} - ${line[1]}"
> done

Thank you for the example.  I'll play around with that just to learn 
more about scripting.

Cheers,

Drew

-- 
Like card tricks?

Visit The Alchemist's Warehouse to
learn card magic secrets for free!

http://alchemistswarehouse.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20130513/32f5166b/attachment.html>


More information about the mythtv-users mailing list