[Wine] Script to run Wine and save log

Austin English austinenglish at gmail.com
Wed Jun 24 14:52:52 CDT 2009


On Wed, Jun 24, 2009 at 2:38 PM, Gert van den Berg<wine-users at mohag.net> wrote:
> Hi all,
>
> I created as little script to run wine and automatically log the
> output and some basic information to a file.
>
> It can be downloaded from here: http://www.mohag.net/wine_with_log
>
> How to use:
> 1. Download (or create) it somewhere and set it executable.
> wget http://www.mohag.net/wine_with_log
> chmod +x wine_with_log
>
> 2. Run application with wine_with_log rather than wine
> 3. Logs can be found in the wine-logs subdirectory (Filenames:
> <command>.<date>.<wine version>.log)
>
> It attempts to run wine-git from ~/wine-git/wine first, followed by
> wine from /usr/local, then wine from /usr and finally the default wine
> (no path specified).
>
> It adds some general information about the environment that it is used
> in at the top of the log. Please check this information before
> uploading / publishing the log publicly to ensure that it contains no
> private information.
>
> Please let me know of any bugs. Other improvements are welcome.
>
> 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).

> Script code: (if wget is impracticable for some reason)
> #!/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=wine
> fi

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.

> 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?

> 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 ';'.

> 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.

> mkdir "$logpath"
>
> logname="$logpath/$1.$date.$winever.log"
>
> echo "----------------------------------------------------------"|tee "$logname"
> echo "Wine version: $winever" |tee -a "$logname"
> echo "WINEPREFIX: '$WINEPREFIX'"|tee -a "$logname"
> echo "WINEPREFIX state: '$wineprefixstatus'"|tee -a "$logname"
> echo "Working directory: '`pwd`'"|tee -a "$logname"
> echo "Date: `date`"|tee -a "$logname"
> echo "OS info (uname -a): '`uname -a`'"|tee -a "$logname"
> echo "Command: '$wine $@'"|tee -a "$logname"
> echo "----------------------------------------------------------"|tee
> -a "$logname"
> wine "$@" 2>&1|tee -a "$logname"

Should be $wine

-- 
-Austin



More information about the wine-users mailing list