Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to run a command from within my MythTV interface on my Mythbuntu computer.

It won't run, and I found this error in my mythbackend.log:

Jul 19 15:55:47 mythbuntu mythbackend[1863]: W SystemEvent mythsystemevent.cpp:55 (run) MythSystemEventHandler: Command '/bin/sh /home/mythbuntu/Buttons/powerbutton.sh' returned 127

I looked up what returned 127 means on Google, and it seems to mean simply "command not found".

But, /bin is on my path...

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/mythbuntu/Buttons:/home/mythbuntu

... and sh is definitely in there:

$ ls /bin/sh
/bin/sh

So why is this command not being found?

share|improve this question
    
Have you looked at the script itself to find out whether it's exiting with that code? –  Scott Severance Jul 19 '12 at 20:55
    
@ScottSeverance: When I run the command directly from a command prompt, it executes perfectly. I assume that means the script is not at fault, and the problems are with what user runs the script, or how that script is accessed. –  Dave M G Jul 28 '12 at 12:49
    
You could try inserting set +x at the beginning of powerbutton.sh. This will cause the shell to print every line of the script as it's executed. That way, you can watch it and hopefully see what's going on. If your calling script is also a shell script, you can try the same thing with it, too. Or, if it's in another language, try running it in a debugger so you can see what's going on. –  Scott Severance Jul 28 '12 at 22:30
add comment

1 Answer

The MythTV backend doesn't have access to X, so it won't be able to run things like xset without setting the environment up properly first. The instructions here are for restarting the frontend via a script that runs via irexec, but it should be easy enough to follow and insert your poweroff script in there.

share|improve this answer
    
Thank you for the suggestion. Unfortunately, neither moving the script to /var/lib/mythtv nor /usr/local/bin worked. –  Dave M G Jul 20 '12 at 1:09
    
what if you sudo su mythtv then run the script? –  tgm4883 Jul 20 '12 at 1:29
    
Thanks for that suggestion too. Unfortunately, that also did not change anything. –  Dave M G Jul 20 '12 at 1:38
    
Exactly, you are running it from the command line as the mythtv user, meaning that for some reason, that user cannot access it. What error message happens when you try that. –  tgm4883 Jul 20 '12 at 5:00
    
When I run the script from the command line, it works perfectly, whether I do it as root, or as a regular user. There is only one user account on the system, named mythbuntu. –  Dave M G Jul 20 '12 at 5:01
show 12 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.