passing pathnames with spaces AND multiple arguments

Questions about Wine on Linux
Locked
AlwaysTrouble
Newbie
Newbie
Posts: 2
Joined: Mon Jul 24, 2017 4:43 am

passing pathnames with spaces AND multiple arguments

Post by AlwaysTrouble »

Hello,
my problem is in summary (detailed below):
- I can pass 2 arguments containing pathnames to a windows script as long as those pathnames do not contain white spaces.
- If there are spaces, this can be fixed by adding quotes around the pathname, but this only works when passing 1 argument, not 2.
- Unfortunately, I need both arguments.

Details:

I have a small .exe compiled for windows that performs some rather sophisticated format conversion. It needs 2 input arguments. The call looks like:

Code: Select all

wine /location/of/exe/xtrx2xtr.exe -c/location/of/some/other/files /even/more/files
This call works fine as long as there are no path names with white spaces within them. If there is, a call like

Code: Select all

wine "/location/of/exe/xtrx2xtr.exe" "/even more files"
(i.e. omitting the one input argument) works in the sense that the application is recognized and run, as well as the path with spaces "/even more files" is recognized and files contained are reported found, but the without the second path the conversion can't be completed.

The calls (with quotes in different positions)

Code: Select all

wine "/location/of/exe/xtrx2xtr.exe" -c"/location/of/some/other/files" "/even more files"
wine "/location/of/exe/xtrx2xtr.exe" "-c/location/of/some/other/files" "/even more files"
wine "/location/of/exe/xtrx2xtr.exe" "-c/location/of/some/other/files /even more files"
start the application, but it will neither understand where the files given with -c are located, nor find "/even more files".

Unfortunately, the spaces can't be avoided.

Thanks for reading/maybe helping!

AP

(using wine-2.12 on openSUSE Leap 42.2)
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: passing pathnames with spaces AND multiple arguments

Post by Bob Wya »

AlwaysTrouble wrote:...

Code: Select all

wine "/location/of/exe/xtrx2xtr.exe" "/even more files"
...
Boy, boy you really need to learn to be more concise! :roll:

At a quick glance you would want to change to:

Code: Select all

wine start 'C:\ ... \xtrx2xtr.exe'
See:

Code: Select all

wine start /?
There are options to specify a Unix path, etc.

Your arguments should be genuine Window paths.
If you don't need command line switches - then something like:

Code: Select all

wine start 'C:\ ... \xtrx2xtr.exe' 'file1' 'file2'
should work... Where say:

Code: Select all

file1 = C:\example1.txt
file2 = C:\example2.txt
Unless your application's command line parser is broken of course!

If following these suggestions doesn't help...

Then please actually give us some concrete examples of what you are trying to do - in the "real world"...
In other words with real input file names, command line switches (if your application needs them), etc.

Remember the Unix shell will parse the command line you type - before Wine sees it!

Bob
AlwaysTrouble
Newbie
Newbie
Posts: 2
Joined: Mon Jul 24, 2017 4:43 am

Re: passing pathnames with spaces AND multiple arguments

Post by AlwaysTrouble »

Ok, thank you for the reply!

It pointed me in the right way. There were some things I had not understood about wine, but assumed I would have, which I educated myself about now. For example, I was not aware that there is something like a virtual C drive, as passing standard unix filenames used to work fine for me. However, going this way became complicated quickly as I am dealing with external disks and such, so I really don't want to have to adapt the wine settings every time.

So the easiest solution for me turned out to be to make a temporary link to a folder with a name that wine can read, which is destroyed after the action. It's a workaround that does the job for me (It still throws some error message about stub or such, but it runs.).

Thanks again!

AT
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: passing pathnames with spaces AND multiple arguments

Post by Bob Wya »

You can also pass full Unix paths to Wine - converting them "on-the-fly" to Windows paths using the winepath utility:

Code: Select all

export UNIX_PATH_1="..." UNIX_PATH_2="..."
wine start 'C:\Program Files\...\<myapp>.exe' "'"$(winepath -w "${UNIX_PATH_1}")"'" "'"$(winepath -w "${UNIX_PATH_2}")"'"
Note:
You've got to use single quotes ' or your shell will eat all the backslashes \ in the path!
(Curse Windows for doing everything backwards - for no good reason!!)
But single quotes around an expression ' wouldn't allow BASH variable expansion or running commands within that expression - hence the complicated: "'" wrappers.

For reference: BASH Hackers Wiki: Quotes and escaping ...

Bob
Locked