CrossOver Support - Community Forums

Important Information These are community forums and not official technical support. If you need official support: Contact Us

CrossOver Mac
Discussion about CrossOver Mac

The following comments are owned by whoever posted them. We are not responsible for them in any way.

Back to Threads Reply to Thread

invoke wine like command in a shell script

Sometimes I use shellscripts for various operations. In one of these scripts I invoke an exe to do something. On a linux machine I just typed "wine <path/to/exe> <parameters here>" to do the job. I'd use crossover on mac (8.0.2) to do the same but I haven't figured out how. One possibility I tried was to execute /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/cxstart <path/to/exe>, similar to the linux command i found elsewhere in an other forum, but then following error occurred:

_X11TransOpen: Unable to find transport for tcp
_X11TransOpen: Unable to find transport for tcp
_X11TransOpen: Unable to find transport for tcp
_X11TransOpen: Unable to find transport for tcp
_X11TransOpen: Unable to find transport for tcp
_X11TransOpen: Unable to find transport for tcp
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.

In my script I need to start the application and wait for a special output (commandline output like the wine command output) then kill the application.
How can I do that? Or isn't it possible with crossover?

It's possible, but not straightforward.

First of all, Wine still uses X11 for windowing and 2D graphics, even on the Mac. CrossOver has an X server built into it, and CrossOver's Wine uses CrossOver's X server and X libraries. It doesn't work with Apple's X11.

So, CrossOver has to be running in order to use its Wine (at least, the GUI parts of Wine).

CrossOver sets up several environment variables for the processes it launches. Several of these are used to let Wine find CrossOver's X11 libraries and connect to the server. CrossOver picks a display number (DISPLAY) dynamically at startup so that it doesn't conflict with other instances of CrossOver (or CrossOver Games) that might be running, including by other user accounts which might be switched out by Fast User Switching. However, once CrossOver picks a display number that nobody else is using, it remembers it and tries to use that same one on next launch. In theory, then, CrossOver should use a relatively stable display number.

CrossOver.app can be relocated, which is a very unusual thing for an X11 environment. (Most are tied to a very specific directly, like /usr/X11, and break if you move them.) We have hacked on the X11 libraries to allow them to work from any location, but some of the libraries need a hint in the form of environment variables as to the actual location.

Try this: from CrossOver's Programs menu, select Run Command. Toggle open the Debug Options section of the Run Command dialog. Click on Open Shell. That will open a new Terminal window and issue a number of commands to configure the shell for accessing CrossOver's Wine. (The first window opened that way can sometimes be misconfigured due to timing bugs in the scripting frameworks. You might want to close the first window and click Open Shell a second time.)

The relevant variables for relocatable X11 are:

FONT_ENCODINGS_DIRECTORY
FONTCONFIG_ROOT
FONTCONFIG_PATH
DYLD_FALLBACK_LIBRARY_PATH

They include the path to CrossOver.app. So long as you don't move CrossOver.app, you can grab the values for those variables and set them in your shell script. The PATH also includes the path to CrossOver.app, and you can either copy that or just use absolute paths to the tools.

To have your script work with a bottle other than the default, you can either set CX_BOTTLE or pass "--bottle <bottle name>" as an option to the "wine" command.

You probably don't need CX_ROOT or CX_BOTTLE_PATH. They are used for some of our non-Wine tools (e.g. cxbottle) and those tools can usually compute the values. If you do plan to use those tools from your script, you'll have to set VERSIONER_PERL_PREFER_32_BIT=yes for Snow Leopard.

To set DISPLAY, you can just copy the value in use at any given time (as shown by Open Shell) and hope that it remains stable over time. If it changes, you'll have to update your script. Alternatively, you can read the most recently recorded display number from CrossOver's preferences using a command like:


defaults read com.codeweavers.CrossOver Display

Once you've got all those environment variables set, your scripts should work. (You'll probably see several other environment variables being set by the Open Shell feature. Most are just things which are copied incidentally from the environment that CrossOver.app inherited from launchd. You can ignore anything I didn't call out specifically, above.)

Good luck. 😊

Thanks a lot for this really detailed explanation, with that in mind it shouldn't be a big challenge to get this working! I recently upgraded to Snow Leopard and now facing other problems like

Can't load '/System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/Mac/Files/Files.bundle' for module Mac::Files: /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/Mac/Files/Files.bundle: no appropriate 64-bit architecture (see "man perl" for running in 32-bit mode) at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/DynaLoader.pm line 207, <DATA> line 1.
 at /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/lib/perl/CXBottle.pm line 66
Compilation failed in require at /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/lib/perl/CXBottle.pm line 66, <DATA> line 1.

wich should be fixed first. That 64bit conversion isn't that easy as it seems 😉 I saw you're already working on some Snow Leopard Issues and I'll keep an eye on them. If a new CrossOver build is available I'll (re-)test my script and report if it has worked for me or not...

Version 8 of CrossOver (Pro, Standard, and Games) supports running on Snow Leopard. The problem you report above is exactly what is addressed by that bit about VERSIONER_PERL_PREFER_32_BIT=yes in my previous post. 😊

Oops! I edited the script when I was on Leopard, after upgrading I didn't read your post again, wich was my mistake. Now with:


# Start CrossOver, otherwise it won't find X11 Server later
open -a CrossOver

# now setting the variables
export 'DYLD_FALLBACK_LIBRARY_PATH'='/Applications/CrossOver.app/Contents/SharedSupport/X11/lib:/Users/<username>/lib:/lib:/usr/lib:/usr/X11/lib'
export 'FONTCONFIG_ROOT'='/Applications/CrossOver.app/Contents/SharedSupport/X11'
export 'FONTCONFIG_PATH'='/Applications/CrossOver.app/Contents/SharedSupport/X11/etc/fonts'
export 'FONT_ENCODINGS_DIRECTORY'='/Applications/CrossOver.app/Contents/SharedSupport/X11/lib/X11/fonts/encodings/encodings.dir'
export 'VERSIONER_PERL_PREFER_32_BIT'='yes'
export 'CX_BOTTLE_PATH'='/Users/<username>/Library/Application Support/CrossOver/Bottles'
export 'CX_ROOT'='/Applications/CrossOver.app/Contents/SharedSupport/CrossOver'
export 'CX_BOTTLE'='winxp' # <-- Enter bottle you want to start

# determine dynamically the used display
export 'DISPLAY'=':'$(defaults read com.codeweavers.CrossOver Display)

# extending the path variable (in front of everything, because there is maybe a wine installation from fink or macports, wich you won't need anymore ;-))
export 'PATH'='/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin:'$PATH

# Invoke a wine command
wine <path/to/exe> <parameters>

Replace the <username> placeholders above and everything works just fine! Thanks again for your help!

Please Note: This Forum is for non-application specific questions relating to installation/configuration of CrossOver. All application-specific posts to this Forum will be moved to their appropriate Compatibility Center Forum.

CrossOver Forums: the place to discuss running Windows applications on Mac and Linux

CodeWeavers or its third-party tools process personal data (e.g. browsing data or IP addresses) and use cookies or other identifiers, which are necessary for its functioning and required to achieve the purposes illustrated in our Privacy Policy. You accept the use of cookies or other identifiers by clicking the Acknowledge button.
Please Wait...
eyJjb3VudHJ5IjoiVVMiLCJsYW5nIjoiZW4iLCJjYXJ0IjowLCJ0enMiOi01LCJjZG4iOiJodHRwczpcL1wvbWVkaWEuY29kZXdlYXZlcnMuY29tXC9wdWJcL2Nyb3Nzb3Zlclwvd2Vic2l0ZSIsImNkbnRzIjoxNzA4NjEzODE4LCJjc3JmX3Rva2VuIjoiYUpDbjZXOGFmekdOS3BOWCIsImdkcHIiOjB9