Execute Shell Commands from Program running in WINE
Edit: user1182474's comment is correct; Wine doesn't isolate the programs it runs. (It tries to hide it, but not very thoroughly.) I totally failed at using Google. Psen's comment below is more correct, and references the FAQ. (Note that, for that to work, you may need to have the program's directory available through a Wine drive mapping. Or, see Anonymous Replier's answer.)
== Old Answer ==
Wine isolates the programs it runs. The applications are, if all works as intended, presented with an environment indistinguishable from Windows. Unfortunately for your purposes, that means that you can't access the features of the host OS (Linux). I mean, you could patch Wine to do that, but I get the impression that it would be more work than it's worth.
There is hope! Cygwin is a Unix-like environment for Windows. You could install Cygwin in Wine, and use Cygwin to run your shell script. (Apparently, installing with 'winetricks cygwin' is easiest) Invoke Cygwin's bash shell (inside some Wine program) like this:
c:\cygwin\bin\bash myscript
Of course, change c:\cygwin to wherever you install it.
Running WINE on bash ubuntu
WINE is going to want the fake Windows path, not the real linux one. Example:
wine "D:\Setup\URPROG.EXE"
Here's the documentation.
You can run it with the local path if you do 'wine start' like this (from the docs):
wine start /Unix "$HOME/installers/TronSetup.exe"
How to execute shell scripts from 32-bit Wine on 64-bit Linux?
I am a user of the program in question and I did some experimenting with it.
Not 32-bit vs. 64-bit but "shared object" vs. "executable" ?
Running file /bin/dash
it prints:
/bin/dash: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), ...
Running file /bin/bash
however prints:
/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), ...
dash
is a "shared object" while bash
is an "executable". Clearly /bin/dash
seems to work like an executable in some way (I don't know the technical details here), but it seems that this difference matters to Wine.
I got the same error as you reported (can't start 64 bit process) for Wine 1.4, but the error I got on newer versions of Wine was wine: Bad EXE format for Z:\bin\sh..
If you actually just replace /bin/sh
with /bin/bash
(even though that's a 64-bit binary) it will work. Wine also didn't seem to like running a symlink, but copying over /bin/bash
worked.
So first back up the existing (symlinked) /bin/sh
with:
sudo cp /bin/sh /bin/sh_orig
Then copy bash
to sh
:
sudo cp /bin/bash /bin/sh
Then when I ran Wine with the program and its calls to /bin/sh
work fine.
Alternatively, you download a 32-bit shell directly
Pull down the .deb file for the 32-bit bash shell:
wget http://us.archive.ubuntu.com/ubuntu/pool/main/b/bash/bash_4.3-6ubuntu1_i386.deb
I your home directory, extract it into a folder:
mkdir ~/bash_4.3-6ubuntu1_i386
dpkg -x bash_4.3-6ubuntu1_i386.deb ~/bash_4.3-6ubuntu1_i386
Copy the bash script into /bin/sh:
sudo mv /bin/sh /bin/sh64original
sudo cp ~/bash_4.3-6ubuntu1_i386/bin/bash /bin/sh
sudo chown root:root /bin/sh
Or run schroot
, but still must copy /bin/bash to /bin/sh
Basile Starynkevitch mentioned above about setting up a 32-bit shell in an schroot
environment. I did that with an Ubuntu 14.04 32-bit environment and ran into the same issue with the dash
vs. bash
"shared object" vs. "executable" (but when I copied /bin/bash
to /bin/sh
it worked), so that helped me realize that the distinction wasn't the 32-bit vs. 64-bit difference but the format of the shell executables that mattered to Wine.
If you would like I can post details for setting up the schroot
evnironment but basically I followed the instructions at https://help.ubuntu.com/community/DebootstrapChroot but needed to configure the /etc/apt/sources.list
to have the full list of packages (as are installed in my default host system) for apt-get install wine
to work.
Related Topics
Can You Prevent a Command from Going into the Bash Shell Command History
Linux Usb: Turning the Power on and Off
Replace Whitespaces with Tabs in Linux
What Is Raw Socket in Socket Programming
Using Grep to Search for a String That Has a Dot in It
Control Mouse by Writing to /Dev/Input/Mice
Redirect All Output to File Using Bash on Linux
Convert All File Extensions to Lower-Case
Colors with Unix Command "Watch"
How to Read a .Properties File Which Contains Keys That Have a Period Character Using Shell Script
What Is a Sysroot Exactly and How to Create One
Is There an Equivalent to Com on *Nix Systems ? If Not, What Was the *Nix Approach to Re-Usability
Recursive Copy of a Specific File Type Maintaining the File Structure in Unix/Linux
When to Use Kernel Threads VS Workqueues in the Linux Kernel
How to Reinstall the Latest Cmake Version