0

I'm trying to use Torrent-Video-Player script but it doesn't works with files that contains spaces. It's a Nautilus script.

#!/bin/bash
xterm -e "peerflix "$1" --vlc"

"test.torrent" -> OK
"test test.torrent" -> Cannot execvp peerflix test : No such file or directory found

1
  • Why do you have nested quotes? Commented Apr 21, 2014 at 19:41

1 Answer 1

3

Change the line

xterm -e "peerflix "$1" --vlc"

to

xterm -e "peerflix '$1' --vlc"

or

xterm -e "peerflix \"$1\" --vlc"

The first form is equivalent to:

xterm -e "peerflix " $1 " --vlc"

It's not what you were expecting.

Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately this is incorrect. -e accepts multiple parameters (so that it would pass them as parameters as well). Your solution might break if you have other special characters inside (like quotes) What you want is xterm -e 'peerflix' "$1" '--vlc' Or you can omit single quotes xterm -e peerflix "$1" --vlc. However, it does not solve the problem of files with leading slashes. This should work better (in case peerflix supports it, but I don't know). xterm -e peerflix --vlc -- "$1"
@Aleks-DanielJakimenko, you are on a rampage, without taking the time to understand some of these questions and answers. In this case, the literal $1 has to be passed to peerflix. It is not to be expanded.
@RSahu please look again. It SHOULD be expanded, because you suggested to change it to "peerflix '$1' --vlc" (which clearly expands it). So, in your answer it expands, so I kept that. Looking again at the question confirms my assumption that it should expand (because he is saying that it works without a space and doesn't with arguments containing a space).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.