0

I have a windows application and i am using WineHQ on my mac to run this app. The application is a specific numerical solver for physics. Everytime a physics problem is to be solved, certain initial conditions are to be given.

The idea is to develop a bash script that can INSTALL or RUN this numerical solver for the initial condition.

INSTALL: When this app was developed the developer forgot to embed certain files into the app. The app hence requires certain CUSTOM FILES which are to be copy-pasted once the application is installed. [Its not a CRACK].

RUN: Now that the app is installed, everytime i run the solver, i have to specify an initial condition. The initial condition is in INIT_FOLDER. I intend to copy this folder to /APP and then run the APP.exe.

I am writing a bash script for the same.

#! /bin/bash
if [ $1 = "INSTALL" ]; then
    wine [APP MAC PATH] APP.exe
    cp [CUSTOM FILES PATH]/ ~/.wine.../APP
    cd ~/.wine.../APP
else 
    if [ $1="RUN" ];  then
        cp $2 ~/.wine.../APP
        cd ~/.wine.../APP
        wine APP.exe
    fi
fi

The end goal is to run the following commands,

>>./scriptname INSTALL
>>./scriptname RUN INIT_FOLDER_PATH

INSTALL: Of course when i run the command to install the application, i do not come accross any problems. HOWEVER, I want to improve the following script (to educate myself). Suppose the application does not install I.E.

wine [APP MAC PATH] APP.exe 

"fails". How to prevent the subsequent operation from being executed?

Also, I dont want to type the wine folder location. Is their some way to make this easier, like representing the "wine app path" as an equivalent word (say FOO)

RUN: I would like to get some validation on this. If i type,

>>./scriptname RUN INIT_FOLDER_PATH/

Am I write to assume $2 is INIT_FOLDER_PATH. Also is the following command the write way,

cp $2 ~/.wine.../APPFOLDERNAME
  • This should probably be split out into multiple distinct questions. For instance, if `wine foo.exe || exit` or `if ! wine foo.exe; then exit; fi` does not exit when `foo.exe` fails, that's a topic for a separate, standalone discussion on its own (and it's not really a question about "elegance"). – Charles Duffy Nov 17 '17 at 15:54
  • Also, there are bugs in here that http://shellcheck.net/ will catch automatically. – Charles Duffy Nov 17 '17 at 16:00
  • You can set default parameters like this... https://stackoverflow.com/a/33419280/2836621 – Mark Setchell Nov 17 '17 at 16:33
  • You could consider installing Oracle Virtualbox (for free) and running a proper copy of Windows in there with your solver. You can share one, or more, directories on your Mac with Windows and/or drag and drop, copy and paste between macOS and Windows. Best of all, the entire Windows thing is in a single file on your Mac, so you can get rid of the entire pile of rubbish (including all its Service Packs, bugs, viruses, unhelpful paperclip assistants and useless BATCH scripting language) by deleting one single file! – Mark Setchell Nov 18 '17 at 21:57

1 Answers1

0
  1. To keep from specifying the path to your wine executable, insure that the path is in your computer's PATH environment variable. See here on how to do that on a mac. Once done, you can run it simply by specifying the program name.

  2. I'm not sure on the error capturing. You will be running a windows executable inside of your wineHQ environment, so you have two layers of errors. 1) the windows executable and 2) Errors within Wine. You can check out the section talking about environment variables in the wine user guide. Specifically the WineDebug channel option. I'm not sure if that will solve for errors within the windows executable, but it seems like a good place to start. You could also check the return code after running the wine line by checking the return return=$? which will be a code 0-255. 0 being A-OK and any thing else being "Something bad happened on that last command".

I'm not entirely sure what you are asking on the last part of your question. $2 in your case would refer to the string "INIT_FOLDER_PATH/" So your cp $2 ... line would copy whatever is in that folder called "INIT_FOLDER_PATH/" to your ~/.wine... path.

JNevill
  • 46,980
  • 4
  • 38
  • 63