Re: Script to run Wine and save log

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 24, 2009 at 21:52, Austin English<austinenglish@xxxxxxxxx> wrote:
> On Wed, Jun 24, 2009 at 2:38 PM, Gert van den Berg<wine-users@xxxxxxxxx> wrote:
>> TODO:
>> 1. Distro detection with lsb_release if available.
>
> Not all distro's use lsb_release. /etc/release, /etc/issue,
> /etc/redhat-release, etc. are other popular ways to get that info.
> Keep in mind, not everyone uses Linux ;-). `uname -s` will give you
> the OS type (in a portable way).
>
There is a uname -a further down.

lsb_release works nice for identifying the Linux distro, *if* it is
present... (And for now at least, uname should be suffiecient on
non-Linux anyway, except maybe with some OpenSolaris distributions...)

> It'd be better to take WINE as an environmental variable first, that
> way the user can specify which they want. E.g., I keep 'vanilla' wine
> installed in /usr/local/bin, but when testing, may run from
> $HOME/wine-git. Many users have custom versions in random places. You
> should use wine="`which wine`" as a fallback.

Fixed with an ugly hack....

>
>> WINEPREFIX="${WINEPREFIX:-$HOME/.wine}" export state not changed
>
> Not sure what you're trying to do with the 'export ...'. Was that
> meant to a comment? Output to the log?
>

Should have been comment...

>> date=`date +%Y%m%d-%H:%M:%S`
>>
>> if [ -d "$WINEPREFIX" ]; then
>>        wineprefixstatus="Not clean"
>> else
>>        wineprefixstatus="Clean"
>> fi
>
> the '[ ] ; then' isn't portable (just found this out myself ;-) ). Put
> the 'then' on a separate line, remove the ';'.
>

"Why I normally use Perl ;)"

(I *know* it works under bash on Solaris, I usually don't bother with
plain Bourne...)

>> if ! winever=`$wine --version` 2> /dev/null; then
>>        echo "Fatal error: Cannot run wine with command '$wine'!" 1>&2
>>        exit 1
>
> Move this up earlier with the wine check.

Done

> Should be $wine
>
Fixed

Thanks, I could probably do with a more elegant implementation of
setting the wine variable than the "set it, overwrite it
afterwards"-method.. (It should probably default to `which wine` and
only change if a variable is set ($WINE currently).)

Uploaded new version. (I would probably need to do some kind of
version control eventually and actually add version numbers...)

Added some of PleegWat's off-list suggestions as well.

Somethings that would be nice to add (preferably with a proper option parser):
Graphics card model / driver detection (Portability might be hard....)
State of common problematic processes, such as pulseaudio / compiz
Logged in user (`id` should work..)

(I should probably test it on my MacBook and the OpenSolaris box that
I'm planning to install soon...)

Gert

Code:
#!/bin/sh
# wine_with_log: Script for running wine while showing and logging output
# Gert van den Berg, 24 June 2009
# This script is released into the public domain
#
# The script prefers a wine-git in the home directory, followed by a
wine in /usr/local
# and /usr, with the system's default wine version being tried last

logpath="$HOME/wine-logs"

if [ -x "$HOME/wine-git/wine" ]
then
	wine="$HOME/wine-git/wine"
elif [ -x /usr/local/bin/wine ]
then
	wine="/usr/local/bin/wine"
elif [ -x /usr/bin/wine ]
then
	wine="/usr/bin/wine"
else
	wine="`which wine`"
fi

# If WINE is defined, we override $wine
wine="${WINE:-$wine}"

# Get Wine version number
if ! winever="`$wine --version`" 2> /dev/null; then
	echo "Fatal error: Cannot run wine with command '$wine'!" 1>&2
	exit 1
fi

# We don't export WINPREFIX, in case the dault change, but assume a
default of ~/.wine
WINEPREFIX="${WINEPREFIX:-$HOME/.wine}"
date="`date +%Y%m%d-%H:%M:%S`"

if [ -d "$WINEPREFIX" ]
then
	wineprefixstatus="Pre-existing"
else
	wineprefixstatus="Clean"
fi

if ! ( [ -d "$logpath" ] || mkdir "$logpath" 2> /dev/null )
then
	echo "Fatal Error: Cannot create / find log path '$logpath'" 1>&2
	exit 2
fi

logname="$logpath/$1.$date.$winever.log"

( # indentation broken to ensure correct log header output
	echo "----------------------------------------------------------
Wine version: $winever
WINEPREFIX: '$WINEPREFIX'
WINEPREFIX state: '$wineprefixstatus'
Working directory: '`pwd`'
Date: `date`
OS info (uname -a): '`uname -a`'
Command: '$wine $@'
----------------------------------------------------------"
	"$wine" "$@" 2>&1
	echo "----------------------------------------------------------"
) |tee -a "$logname"



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux