2

I want to luanch an wine App with passing a file as argument. I've two file, with the first I don't have any problem but when there is a space in the path wine can't handle the address properly. here is these two files:

/home/op/Doc/test.pdf

/home/op/Doc/test vs space.pdf

from the command line I can successfully launch the app with both files using this command:

[/home/op@box ~]: wine "C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" "z:Docs/test.pdf"

[/home/op@box ~]: wine "C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" "z:Docs/test vs space.pdf"

but when I want to put this in a script (to luanch later with another program, ranger) I can't launch the program with test files. The first script works well with those which don't have any space in the address but the second doesn't work and just lunch the App without the pdf file opened:

Script 1: work with no space case:

#!/bin/bash
Filename="z:${1//\//\\}"

wine "C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" $Filename 

Script 2: Doesn't work in either of cases

#!/bin/bash
Filename="z:${1//\//\\}"
Filename='"'$Filename'"'

wine "C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" $Filename 

echo $Filename

I'm can't get where is wrong with the script (in comparision to the commands issued manually in the shell). The second script doesn't open any type of file, with or without a space in address.

p.s. there is also similar scripts here but they are suffer from the same problem i.e. they can't launch the pdf with a space in the address either.

1

I see several typos, errors in your script which might prevent it from executing it correctly:

#!/bin/bash
Filename="z:${1//\//\\}"
# Filename='"'$Filename'"'
# you can just leave this line, the triple quoting is unnecessary anyway

wine "C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" "$Filename" # it's better to quote variables containing strings

echo "$Filename" # the same here

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.