1

I'm trying to run a Windows executable via wine. When I first try to run it never runs, but when I attempt to do it again, the program runs.

I'd like to make a script to run the program, here's the the important part of the script:

EXECUTABLE=$(env XMODIFIERS="" wine hl.exe .nomaster -strechaspect)
$EXECUTABLE
echo "Exit Status = $?"

With this it never gives me the message "Exit Status 0", because, wine finishes successfully, but the "hl.exe" exits with an error because that didn't start in the first try, just the second try as i stated in the beginning.

I first thought something like this might do:

e=$?
if [ $e -ne 0 ]
then
  echo
  echo "Exit with Error"
  echo
fi

but it never shows me the message "Exit Status = 0".

Can someone help me with how to solve this?

  • 1
    I don't know about wine, but if $EXECUTABLE talks to stdout or stderr you could grep for an error or message which only appears upon failure. $EXECUTABLE | grep "error" when using a pipe, the variable $? has the exit value of the last program in the pipe. If you're interested in this solution, I can make it an answer. – Sebastian Oct 16 '14 at 11:27
  • The script that wraps WINE might have a bug in it. bugs.debian.org/cgi-bin/bugreport.cgi?bug=109668. There was one that was fixed back in 2001, perhaps that fix has some issues with certain edge cases. – slm Oct 16 '14 at 13:07
  • Can you modify your wine command to run something like hl.exe .nomaster -strechaspect & echo %errorlevel%? Possibly writing the errorlevel to a file, to make it easier for the shell script to capture it? (You will almost surely need to quote or escape the & to prevent the shell from interpreting it.) – G-Man Oct 16 '14 at 17:35
1

Ok , i has solve with a workaround , because , it's not possible obtain the wine windows executable exit status code.

Ok i put the follow

EXECUTABLE=$(env XMODIFIERS="" wine hl.exe .nomaster -strechaspect)
$EXECUTABLE
HL1EXE=$(ps -A | grep hl.exe | awk '{print $4}')

if [ -z "$HL1EXE"]; then
       echo
       echo "Try to Launch again wait" 
       echo
       sleep 3
       EXECUTABLE=$(env XMODIFIERS="" wine hl.exe .nomaster -strechaspect)
       $EXECUTABLE
       HL1EXE=$(ps -A | grep hl.exe | awk '{print $4}')
       echo "Executable File : $HL1EXE"
fi

and ready , the game Start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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