Project

General

Profile

Post-procesor command not run

Added by m j over 10 years ago

Hello, I'm trying to configure tvheadend to run a script that will shut down the system after recording (assuming certain conditions are met).
To do this, I've created a script, /usr/local/bin/post-record, and set the post-processor command in tvheadend's settings as follows:
/usr/local/bin/post-record >> /home/xbmc/wakeup.log

I've verified that the script works as expected, and tried logging in as to the system as hts and running the above command manully. The script executes, and output is logged to the file, so all's well there.

The problem seems to be that tvheadend simply isn't executing the command when a recording has finished, and I dont know why. I've tried running tvheadend with debug logging on, but can't see anything that mentions the command or why it might have failed. Does anyone have any suggestions? I'm running HTS Tvheadend 3.4.27~gfbda802~precise on Ubuntu 12.04.


Replies (10)

RE: Post-procesor command not run - Added by Prof Yaffle over 10 years ago

Try /bin/sh /usr/local/bin/post-record >> /home/xbmc/wakeup.log (or whatever shell scripting language you're using, obviously) - especially if you haven't declared the shell type at the start of your script (i.e. #!/bin/sh or similar as your first line)

RE: Post-procesor command not run - Added by m j over 10 years ago

Thanks for the reply.

post-record is a ruby script, with #!/bin/env ruby as the shebang.
I've tried prefixing the command with both ruby and /usr/bin/ruby (both of these work as expected from the shell) but to no avail.

RE: Post-procesor command not run - Added by Prof Yaffle over 10 years ago

What shell are you launching the script from when you're at the command line? Try that - spawn a bash and let that call ruby (for example).

RE: Post-procesor command not run - Added by m j over 10 years ago

I'm using bash. I've tried /bin/bash /usr/local/bin/post-record >> /home/xbmc/wakeup.log and /bin/bash -c "/usr/local/bin/post-record >> /home/xbmc/wakeup.log" but as the post-processor command but still no joy.

RE: Post-procesor command not run - Added by Prof Yaffle over 10 years ago

More random thoughts, then...!

Related to the redirection, perhaps? Does it work without the redirect, or if you do something like >> wakeup.log 2>&1?

Is the script accessible and executable to the UID that's running tvheadend (e.g. hts:video)?

RE: Post-procesor command not run - Added by m j over 10 years ago

It didn't work without the redirect, I added it to see if I could work out whether it was running or not. 2>&1 doesn't seem to help.

The script's mode is 755, the log file is 777, and I've verified that logging in as hts:video allows me to execute the script.

RE: Post-procesor command not run - Added by Prof Yaffle over 10 years ago

Hmmm. Can you share the script? I have to suspect it's something in there, then, because everything else looks okay... happy to give it a whirl on my rig if you like.

RE: Post-procesor command not run - Added by m j over 10 years ago

Sure, I've stuck it in a GitHub Gist here: https://gist.github.com/marxjohnson/11356234
Thanks!

RE: Post-procesor command not run - Added by Prof Yaffle over 10 years ago

Without running it, I'd still point an accusing finger at your shebang definition. You've got #!/usr/bin/env ruby - is this valid for the hts user, though? Is ruby in the PATH when this script is spawned even if it's in your path when you open a shell to test it?

Three thoughts:

1. Try a new script that dumps env to a file; call that as a test; see what PATH is defined and whether ruby is thus valid
2. Explicitly define the PATH when calling the existing script
3. Explicitly define the path to ruby instead of relying on /usr/bin/env

RE: Post-procesor command not run - Added by m j over 10 years ago

Success!
I tried various things inspired by your comments.

First I created the following bash script and set it to run as the post-processor command:

#!/bin/bash
/usr/bin/env > /home/hts/out

Which worked, although showed nothing unexpected (PATH contained /usr/bin et al).
So, I copied the ruby script and removed the shebang, then edited the bash script to:
#!/bin/bash
/usr/bin/ruby /usr/local/bin/post-record.rb >> /home/xbmc/wakeup.log 2>&1

Which ran, but showed that the environment it ran in triggered a bug in the version of Ruby available in Ubuntu 12.04.

So, I installed rvm and installed a newer version of ruby, then changed the bash script to

#!/bin/bash
source /etc/profile.d/rvm.sh
rvm use 2.0
ruby /usr/local/bin/post-record.rb >> /home/xbmc/wakeup.log 2>&1

And it worked!

Thanks very much for your help :)

    (1-10/10)