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

melkir
  • 405
  • 1
  • 5
  • 22

1 Answers1

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.

R Sahu
  • 204,454
  • 14
  • 159
  • 270
  • 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-Daniel Jakimenko-A. Jul 02 '14 at 05:59
  • @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. – R Sahu Jul 02 '14 at 06:03
  • @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). – Aleks-Daniel Jakimenko-A. Jul 02 '14 at 06:18