views:

50

answers:

2

I have made a script to open Spotify with wine:

#!/bin/bash
DIR="/home/jorgsk/.wine/drive_c/Program Files/Spotify/"
cd "$DIR"
wine spotify.exe 2>/dev/null

I'm passing "$DIR" to cd with quotes because of the whitespace in "Program Files"; if I don't have the quotes "/home/jorgsk/.wine/drive_c/Programs" will be considered as the argument to cd, which obviously will result in an error message.

Spotify starts fine if I launch the above script from its local directory (/home/jorgsk/bin) with ./spotify. However, since I wish to launch it from wherever, I have /home/jorgsk/bin added to the $PATH variable in .bashrc. When I write "spotify" from for example my home directory, I get the error message

bash: /home/jorgsk/.wine/drive_c/Program: No such file or directory

which is the same error message I get if I don't include $DIR in quotes when launching tje script with ./spotify from the script's directory.

What is happening here?

A: 

I'm not sure why this is happening - looks like it should work to me.

You say this is in your path but is that the version that is actually being called?

Try running: which spotify from your home directory. The which command tells you the path of the script that runs.

Adam Butler
A: 

I don't know the answer but I think I can give you a procedure that will identify the issue.

Add set -x to have the script echo the lines it is running.

 #!/bin/bash
 set -x
 DIR="/home/jorgsk/.wine/drive_c/Program Files/Spotify/"
 cd "$DIR"
 wine spotify.exe 2>/dev/null

Also, name the script something other than spotify. Although it doesn't immediately look like it would matter, who knows what complex behavior is happening once wine gets control?

DigitalRoss
Adding set -x did nothing, it just gave the same error as before. When I renamed the file to 'testme', Spotify launched and I got the output from the script as expected.
Viktiglemma
In other words, it works now! It seems that Wine must have a some kind of shortcut to spotify somewhere that I can't find. Yet mysteriously, "which spotify" gives "/home/jorgsk/bin/spotify"!
Viktiglemma
@Viktiglemma: Do `type -a spotify` instead of `which spotify`. It may tell you if there is an alias or function that is taking precedent over the executable in your `PATH`.
Dennis Williamson
Indeed, there was an alias set for spotify... I have to admit that I set it myself and then later forgot about it. Regardless, I have learnt a lot, thanks for the answers.
Viktiglemma
Aha, that was what the "-x" was supposed to find. (It wasn't supposed to fix anything, it was just supposed to debug the script...)
DigitalRoss