LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 03-22-2008, 11:23 AM   #1
broxtor
Member
 
Registered: Jul 2003
Location: The Netherlands
Distribution: Debian Squeeze AMD64
Posts: 94

Rep: Reputation: 16
Execute script with irexec from mythtv


I have a mythtv box that mounts a couple of NFS shares on boot. But sometimes the machines that have the NFS shares are not running, so obviously those shares aren't mounted. When I later turn on the machines that have the shares I have to restart my mythtv box in order to get the shares mounted.
I order to not have to do this I created a shell script that mounts those NFS shares. I want to execute this script when I press a button on my remote control. I made the following entry in my .lircrc file:
Code:
begin
     remote = Hauppauge_350
     button = Red
     prog = irexec
     repeat = 0
     config = /home/mythtv/mountshares.sh
end
When in Mythtv I press the corresponing button on my remote, nothing happens.

I tested the script from the commandline and that works. I also checked whether irexec is running and it is. I even restarted irexec and specified the .lircrc file it should use, but it doesn't help. All other functions specified in my lircrc file work correctly, although none of them use irexec. I have mythtv running on Mythbuntu 7.10.
Can someone give me some pointers on how to get this working?
 
Old 03-24-2008, 02:39 AM   #2
anotherlinuxuser
Member
 
Registered: Jan 2007
Location: Alberta Canada
Distribution: Fedora/Redhat/CentOS
Posts: 64

Rep: Reputation: 19
Here are 2 things to check: Is the execute bit turned on in /home/mythtv/mountshares.sh file permissions? i.e. a ls command should include 'x's in the file permissions. Also does the user mythtv have permission to mount the NFS shares?
A quick test to find out if the script is being executed is to put a line like: 'date > /tmp/check.txt' into the script. This way you can determine if irexec is really running the script or not. Another thing to add to the script would be redirecting the mount command's output to a file as well. For example: 'mount /var/myshare > /tmp/check.txt 2>&1' This way if the mount is failing for some reason, you will have the error output in /tmp/check.txt to see what the problem is.

Good luck.
 
Old 03-24-2008, 05:20 AM   #3
broxtor
Member
 
Registered: Jul 2003
Location: The Netherlands
Distribution: Debian Squeeze AMD64
Posts: 94

Original Poster
Rep: Reputation: 16
Hi, Thanks for your help. Here are my findings.

The script is executable by user mythtv. When I run it from the command line it works like it should.
I also added the lines to script to get some output in the logs. I also tested this from the commandline and that works also.
I then tried to run the script with my remote and irexec. At that point the log remains empty, so it looks like the script isn't executed by irexec.
 
Old 09-10-2008, 03:17 PM   #4
leeko
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Rep: Reputation: 0
Any joy with this?

Hi,

did you ever find an answer to this? I'm having the exact same problem, only my script is to suspend the computer. Script works form the CLI, but not when called by irexec. I think there is a major bug in irexec somewhere...

Please let me know if you found a workaround!

Regards,

Lee
 
Old 09-11-2008, 03:00 AM   #5
anotherlinuxuser
Member
 
Registered: Jan 2007
Location: Alberta Canada
Distribution: Fedora/Redhat/CentOS
Posts: 64

Rep: Reputation: 19
This is puzzling. I have a number scripts I run using various remotes with irexec.
I have my .lircrc file in my home dir, not the .mythtv subdir.
Here's one thing to try: run irexec from a terminal window without the -d option. This way, if irexec is not running the script for some reason, it may report an error to the terminal window. For example, I purposely put an invalid path in the .lircrc file on the 'config = ...' line for my power button. When run in non-deamon mode from a terminal, irexec reported:

'sh: /usr/local/yyybin/myth_power: no such file or directory'

I don't know if it will help, but it's worth a try.

Last edited by anotherlinuxuser; 09-11-2008 at 03:01 AM.
 
Old 09-11-2008, 02:31 PM   #6
leeko
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Rep: Reputation: 0
Hi,

Thanks for the reply. When I run irexec manually, logged in as user leeko, it works fine. I can use the remote to suspend the computer. It just doesn't work when I try to autostart irexec at login.

I've tried autostarting irexec as leeko, mythtv and root. None of them allow it. I've also added a "sleep 30" line to the startup script, because another user noted that irexec doesn't work if it's started too close to lirc - no joy.

I posted this problem on another forum, but haven't had any response. Here's the full post:

-----------------------
Hi everyone,

Sorry for the long post - I've been working at this for a while :P

I'm trying to get lirc and irexec to allow me to suspend my computer from the remote control (packard bell fastmedia serial remote). I had problems when running irexec as myself (leeko), and major issues with trying to get it to run as user mythtv (suggested on another forum). Eventually, I rewrote my sudoers file and it now runs as mythtv. Unfortunately, even running as mythtv does not allow irexec to call the suspend script. I even tried running it as root, and it still doesn't work.

Here is my complete setup:
- Mythbuntu 8.04, fully up-to-date
- Set to auto-login as user leeko
- lircd autostarts as root user. All lircd functions work perfectly within mythtv/mplayer
- An irexec daemon autostarts as user leeko. I don't know where this is set to do this. I have removed all entries from /config/autostart, and rc.local, and I don't have any scripts set. So, I autorun a script: /usr/local/bin/irexeclauncher. This script kills the existing irexec process, waits 30 seconds, then restarts it as user mythtv (or root). This works fine now.

Code:
leeko@leeko-media:~$ cat /usr/local/bin/irexeclauncher
#!/bin/bash
# Launcher for IREXEC because it's STUPID and won't launch properly in startup scripts!
sleep 10
killall irexec
sleep 30
sudo -u mythtv irexec /home/leeko/.lircrc
#sudo irexec /home/leeko/.lircrc
exit 0
- After giving the script time to run, "ps aux | grep ir" shows:
Code:
leeko@leeko-media:~$ ps aux |grep ir
root         4  0.0  0.0      0     0 ?        S<   11:43   0:00 [ksoftirqd/0]
mysql     4977  0.1  3.6 128268 18624 ?        Sl   11:43   0:01 /usr/sbin/mysqld --basedir=/usr--datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
root      5495  0.0  0.1   2932   584 ?        S<s  11:44   0:00 /usr/sbin/lircd --device=/dev/lirc0
leeko     5913  0.0  0.2   4264  1428 ?        Ss   11:44   0:00 /bin/bash /usr/local/bin/irexeclauncher
mythtv      5979  0.0  0.1   1716   516 ?        S    11:44   0:00 irexec /home/leeko/.lircrc
leeko     6862  0.0  0.1   3008   772 pts/1    R+   12:06   0:00 grep ir
- My /home/leeko/.lircrc file has an entry to call /home/leeko/scripts/suspend.sh when I press button "SRS" on the remote:
Code:
leeko@leeko-media:~$ cat /home/leeko/.lircrc
#Custom lircrc generated via mythbuntu-lirc-generator
#All application specific lircrc files are within ~/.lirc
include ~/.lirc/mythtv
include ~/.lirc/mplayer
include ~/.lirc/xine
include ~/.lirc/vlc
include ~/.lirc/xmame
include ~/.lirc/xmess
include ~/.lirc/totem
include ~/.lirc/elisa
# include ~/.lirc/irexec

begin
    remote = PackBell
    prog = irexec
    button = SRS
    config = /home/leeko/scripts/suspend.sh
    repeat = 0
    delay = 0
end
- Here are the contents of the suspend.sh script:
Code:
leeko@leeko-media:~$ cat scripts/suspend.sh
#!/bin/bash
sudo /usr/sbin/pmi action suspend
- Immediately after login, I am able to manually suspend the computer using the suspend script. I am not asked for a password, as I have specified that user leeko can run "pmi action suspend" without a password.
-I have tried changing the ownership of the file from "leeko" to "mythtv" - no joy.

My sudoers file:
Code:
# /etc/sudoers
Defaults        env_reset
%admin ALL=(ALL) ALL
leeko ALL = ALL
leeko ALL = NOPASSWD: /usr/bin/irexec
leeko ALL = (mythtv) NOPASSWD: ALL
leeko ALL = NOPASSWD: /usr/sbin/pmi
mythtv ALL = NOPASSWD: /usr/sbin/pmi
mythtv ALL = NOPASSWD: /usr/bin/irexec
mythtv ALL = ALL
mythtv ALL = NOPASSWD: /sbin/halt,/sbin/shutdown,/sbin/reboot,/bin/umount
- My lircd.conf has the following entry for button "SRS"
SRS 0x0000000000004EB1

- Using irw, pressing the button SRS gives:
Code:
leeko@leeko-media:~$ irw
00000000f7089d62 00 SRS PackBell
00000000f7089d62 01 SRS PackBell
As far as I can tell, everything is set up correctly. I can't figure out why irexec won't do what I'm asking!

My only clue is auth.log. Whenever I press the power button, auth.log appends this to the tail:

Code:
Sep 10 12:31:47 leeko-media sudo: pam_unix(sudo:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=mythtv
Any help with this issue would be very much appreciated. I'm knackered from getting up off the couch to switch this machine off!

Thanks,

Lee
----------
 
Old 09-11-2008, 02:45 PM   #7
leeko
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Rep: Reputation: 0
How very weird!

How incredibly weird!

As an act of desperation, I tried one last thing in the script:

- kill the rogue autostarted "irexec -d /home/leeko/.lircrc" process, which was owned by user leeko
- wait 30 seconds
- restart irexec as the same user, leeko, with "irexec /home/leeko/.lircrc" (no daemon flag this time).

It works this time - pressing the power button suspends the computer. Woooo!

I conclude that irexec:
- doesn't work properly when autostarted
- doesn't work properly when the -d flag is set
- is a pain in the backside to get working properly!

Of course, these conclusions only hold true for my setup (which is not too unusual...).

Thanks for the input,

Lee
 
Old 09-12-2008, 01:14 AM   #8
anotherlinuxuser
Member
 
Registered: Jan 2007
Location: Alberta Canada
Distribution: Fedora/Redhat/CentOS
Posts: 64

Rep: Reputation: 19
The problem with starting irexec at startup/logon may be that the DISPLAY var is not set.

To see the system assigned value for the DISPLAY var, enter this in a terminal window:

env | grep DISPLAY

The result will look like: DISPLAY=:0.0

In your script, before running irexec, add this line:

export DISPLAY=0.0

If that doesn't work, try

export DISPLAY=0

Replace the zeros with the numbers displayed by your system.
 
Old 09-12-2008, 06:33 AM   #9
leeko
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Rep: Reputation: 0
But, why would it matter what display it's on? My irexec only does one thing; calls a script which sends the computer into S3 suspend mode. Surely the display shouldn't matter?

Lee
 
Old 09-13-2008, 03:59 AM   #10
anotherlinuxuser
Member
 
Registered: Jan 2007
Location: Alberta Canada
Distribution: Fedora/Redhat/CentOS
Posts: 64

Rep: Reputation: 19
irexec is a lightweight program. It can be used to launch any program. If it is used to launch firefox,
for example, it needs a display to open the window on. Irexec has to assume it will need to open to a
window because it lacks the ability to dynamically determine the active display. Therefore, the DISPLAY
var must be set when irexec starts so that its read into irexec's environment.

Give it a try.
 
Old 12-13-2008, 04:43 PM   #11
bkirkman
LQ Newbie
 
Registered: Dec 2008
Posts: 1

Rep: Reputation: 0
tty and sudo

Lee,
I was running into the same problems as you and spent several hours trying to figure this out. I spent a lot of time looking at your setup and gleaned some good info from it. The following solved my issues, and I hope it can help you out as well. I tried replying on your blog, but I couldn't find a place to register.

When irexec is autostarted at login, in this case by a user, it doesn't have a tty terminal value. Check out your "ps aux | grep ir" above. Sudo doesn't like to be told what to do from something that doesn't apparently come from a terminal, and since irexec is the program actually executing your suspend script (I guess?), which is sudo'd, sudo won't run. But have no fear!!

Try editing your sudoers file using visudo, and comment out the following line.

Code:
#Defaults    requiretty
Once I did this, irexec fired off my sudo'd shutdown script without a hitch. It was a great relief!! Other scripts that are called by irexec that aren't sudo'd shouldn't care about the tty issue. Even though this topic is a few months old, I hope it can still help you out.
 
Old 12-14-2008, 12:25 AM   #12
leeko
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Rep: Reputation: 0
hi,

I actually wiped that install, and am now running a different pc which has other issues preventing standby. But, I'm thinking about installing mythbuntu 8.10 in the hope that it will sort that out... Hopefully this info will prove useful when I get around to that.

Thanks!

Lee
 
Old 02-13-2009, 12:14 PM   #13
halfconscious
LQ Newbie
 
Registered: Oct 2007
Posts: 1

Rep: Reputation: 0
irexec on start problem

I came to this thread after long suffering in a similiar fashion.
irexec worked fine when started from a log in shell but would not run
properly from init or even cron.
I wanted to post back here because my problem was solved when I
changed my lircrc "config" line to have a full pathname.

e.g. in lircrc
I changed the config line below to a full path

begin
prog = irexec
button = AppExit
config = ShutdownBox
end

e.g.
config = /usr/local/bin/ShutdownBox

made all the difference for me.
I guess irexec may well have no sensible PATH set in it's environment
at init or even when run by cron. This is clearly not everyones problem but it might help someone.
Good luck
 
  


Reply

Tags
mythtv, nfs


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute a ssh script on Linux server from Windows through a bat script? wanna13e Programming 13 10-23-2009 03:41 AM
script to parse variables to curl script and execute morphix Programming 17 11-30-2007 02:27 AM
run script from irexec lord_darkhelmet Fedora 0 11-11-2007 04:59 PM
SUSE 10 init script problems with MythTV Shawn Parr Suse/Novell 0 04-19-2006 10:05 PM
irexec problem vijayaramanl Linux - Newbie 1 10-26-2003 09:10 PM


All times are GMT -5. The time now is 12:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration