LinHES Forums
http://forum.linhes.org/

Problems with Wine/TVxb launched via Myth/cron :-(
http://forum.linhes.org/viewtopic.php?f=6&t=11240
Page 1 of 1

Author:  Warped [ Tue Aug 22, 2006 6:54 am ]
Post subject:  Problems with Wine/TVxb launched via Myth/cron :-(

Hi All,

I'm living in country without XMLTV listings provider - so I have to generate them myself.
For this purpose I'm using TVxb and Wine.
TVxb is launched via following script:
----------------------------------------
#!/bin/bash
cd /home/mythtv/grabber/TVxb/bin
cp -f /home/mythtv/.Xauthority /root/
mv -f ./aster.xml ./aster.xml.old
export DISPLAY=:0.0
wine TVxb.exe -NoConsole > /var/log/grabber/tvxb-wine-output.log 2>&1
sleep 2
test -e ./aster.xml || exit 0
mythfilldatabase --file 1 -1 aster.xml > /var/log/grabber/filldatabase-output.log 2>&1
-----------------------------------------

Using this script in Terminal window works without any problem.
But when I configure Myth to launch it periodically (mythfilldatabse in TV/general setup) or via cron - following errors are reported:

-----------------------------------------
Warning:
The Wine launcher is unable to find the xmessage program,
which it needs to properly notify you of Wine execution status
or problems.

This launcher script relies heavily on finding this tool,
and without it, it will behave very poorly.

We strongly recommend that you use your distribution's
software methods to locate xmessage, or alternatively
use your favourite internet search engine to find out
how you are supposed to install xmessage on your system.
Xlib: connection to ":0.0" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key
Xlib: connection to ":0.0" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key
fixme:ttydrv:TTYDRV_GetBitmapBits (0x7c, 0x7fd5425c, 128): stub
fixme:ttydrv:TTYDRV_GetBitmapBits (0x140, 0x7fd581ec, 128): stub


fixme:msvcrt:_XcptFilter (-1073741819,0x7fbeeea4)semi-stub
wine: Unhandled exception (thread 0009), starting debugger...
err:seh:start_debugger Couldn't start debugger ("winedbg 8 84") (2)
Read the Wine Developers Guide on how to set up winedbg or another debugger

Wine failed with return code 5
-------------------------------------------

It looks like enviroment problem manifesting when script is launched via myth or cron.

May somebode hint me where problem might be ?

Million thanx in advance !

Author:  nickread [ Tue Aug 22, 2006 6:36 pm ]
Post subject:  Re: Problems with Wine/TVxb launched via Myth/cron :-(

Warped wrote:
It looks like enviroment problem manifesting when script is launched via myth or cron.

Exactly. You need to set all and any environment variables required when using cron. See this post for ideas:
http://mysettopbox.tv/phpBB2/viewtopic.php?t=10953&highlight=cron+profile

Author:  Warped [ Wed Aug 23, 2006 1:12 pm ]
Post subject:  Re: Problems with Wine/TVxb launched via Myth/cron :-(

Nickread,

I really appreciate Your help, but I need little more details.
In dir ~/myth there is no ./profile file.
I assume I have to use /etc/profile file
I tried following statement in crontab

5 20 * * * mythtv . /etc/profile; /home/myth/grabber/tvgrabber.sh

In logs I see:

Xlib: connection to ":0.0" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key
Error opening terminal: unknown.
Wine failed with return code 1

tvgrabber.sh:
#!/bin/bash
cd /home/mythtv/grabber/TVxb/bin
# cp -f /home/mythtv/.Xauthority /root/
mv -f ./aster.xml ./aster.xml.old
export DISPLAY=:0.0
wine TVxb.exe -NoConsole > /var/log/grabber/tvxb-wine-output.log 2>&1
sleep 2
test -e ./aster.xml || exit 0
mythfilldatabase --file 1 -1 aster.xml > /var/log/grabber/filldatabase-output.log 2>&1

million thanx in advance


nickread wrote:
Warped wrote:
It looks like enviroment problem manifesting when script is launched via myth or cron.

Exactly. You need to set all and any environment variables required when using cron. See this post for ideas:
http://mysettopbox.tv/phpBB2/viewtopic.php?t=10953&highlight=cron+profile

Author:  nickread [ Wed Aug 23, 2006 4:32 pm ]
Post subject: 

http://linux.math.tifr.res.in/manuals/man/cron.html
~ is a shortcut to the home directory of the current user (in this case the owner of the crontab file), should be root
.profile is a hidden file (begins with .) so won't show up unless you use 'ls -a'. So you should have a .profile in /root, which is assuming that when it works from the command line you are doing it as root.

There may be other environment vars used for Wine, I don't know anything about it, but I guess they would be . files in the home directory as well.

Author:  nickread [ Thu Aug 24, 2006 5:33 am ]
Post subject: 

Ok, I'm home now - so I can check whats on my box. You're right, theres no .profile in /root or /home/mythtv, although there is a .bash_profile in /home/mythtv

You won't be able to execute /etc/profile unless you modify the permissions.

The simplest thing to try is to just add a path statement to your crontab file with whatever the path is when its working from the command line (echo $PATH).

Author:  Warped [ Thu Aug 24, 2006 2:33 pm ]
Post subject:  Hmm - I'm confused

Nickread,

Thx for trying help.
In fact I'm little confused :-(
Indeed in ~/mythtv there is bash_profile but all content is commented...
In crontqb I have already setup path to:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

So my question is:
where is file which I should use for setting cron launched environment to the same state like alt-x launched terminal (in which my tvgrabber.sh scrip working well)

pls remember - in KM cron launching session with given user (mythtv here)

br



nickread wrote:
Ok, I'm home now - so I can check whats on my box. You're right, theres no .profile in /root or /home/mythtv, although there is a .bash_profile in /home/mythtv

You won't be able to execute /etc/profile unless you modify the permissions.

The simplest thing to try is to just add a path statement to your crontab file with whatever the path is when its working from the command line (echo $PATH).

Author:  nickread [ Thu Aug 24, 2006 4:31 pm ]
Post subject: 

Just to clarify:

1) What user are you running the script as from the command line? Root or mythtv?
2) Is the path in the crontab the same as the path in the terminal for that user?

Also, the X messages indicate that possibly the cron user does not have permission to access the X display. Maybe it is not running as user mythtv?

I beleive that if you issue the command 'xhost +' from the command line it will allow everyone (inc root) to access the display. Try that before the cron job runs and see. You can turn it off afterwards with 'xhost -'

Author:  khrusher [ Thu Aug 24, 2006 6:04 pm ]
Post subject: 

ok, there is SOMETHING in your login shell that is not availible in your cron environmetn...that is a common problem.

your cron job can source any file...not just a .profile or .bash. i have often created ~/.cron files to set anything needed for cron.

you can start with PATH...
Code:
env | grep PATH > ~mythtv/.cron
echo "export PATH" >> ~mythtv/.cron


then change your crontab to include
Code:
. ~mythtv/.cron


If it still has issues, continue to add env vars to the .cron file until all is well. use the command 'env' to view all environment vars in your current shell.

as for your crontab format, I see you have the 'username format' isnt that reserved for /etc/crontab? is that where you have it? If not, if you are using corntab <filename> to load the cron while logged in as mythtv, you may want to lose the username column from the crtontab file

Author:  Warped [ Tue Aug 29, 2006 2:07 am ]
Post subject:  Ok, now is better :-))))

khrusher,

Big thanx for nice help. I nailed down issue:
I have to add to my script following statements:

export SHELL=/bin/sh
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
export DISPLAY=:0.0
export XAUTHORITY=/tmp/.gdmn5MBcA

Now problem is that XAUTHORITY variable is changing every boot.
Probably there is simple way to overcome this issue, but I haven't time to drill across tons of Linux mans and docs.
Maybe You can hint me....

Thx


khrusher wrote:
ok, there is SOMETHING in your login shell that is not availible in your cron environmetn...that is a common problem.
at
your cron job can source any file...not just a .profile or .bash. i have often created ~/.cron files to set anything needed for cron.

you can start with PATH...
Code:
env | grep PATH > ~mythtv/.cron
echo "export PATH" >> ~mythtv/.cron


then change your crontab to include
Code:
. ~mythtv/.cron


If it still has issues, continue to add env vars to the .cron file until all is well. use the command 'env' to view all environment vars in your current shell.


Author:  khrusher [ Tue Aug 29, 2006 6:48 am ]
Post subject: 

are many folks running xauth on their myth boxes? not here.

While its nice, probably over kill unless you have multiple users on the box at a time...and you dont want or expect the other user to be 'snooping' on your X session.

Author:  Warped [ Tue Aug 29, 2006 7:07 am ]
Post subject: 

Oh well,

So xauth is optional !
How can I switch it off ?


BTW: I see You are using Nv5200. Are You running r5c7 ?
If so - has r5c7 build-in drivers for 5200 or should I install nv drivers separately ?
In my r5c7 I install nv5200 and fresh r5c7 - but I receive some nv related errors during boot. Is it normal or my nv5200 is broken or maybe drivers are missing....


khrusher wrote:
are many folks running xauth on their myth boxes? not here.

While its nice, probably over kill unless you have multiple users on the box at a time...and you dont want or expect the other user to be 'snooping' on your X session.

Author:  khrusher [ Tue Aug 29, 2006 1:48 pm ]
Post subject: 

sorry, im am running the very old R5A16 dated May 2005.

As far as xauth, I dont know much about it...I googled it this morning when i read your post. its basically a more secure xhost.

I'm not saying you need to turn it off, I was just posing the question. Looks to me is that your issue is that xauth limits access to the xserver to a particular session....a session different then you cron session.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/