Afficher un message
Vieux 07/01/2008, 22h28   #1
Andre-John Mas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Getting script location, trouble with spaces

Hi,

I am writing a script and in order to run properly it needs to know
where it is located, in order to be able to find its resources. It
works fine, until the path has a space in it. I having a little
trouble resolving the issue.

#!/bin/sh

cd `dirname "$0"`
pwd
java -cp lib/myjar.jar:lib/icu4j-3_8.jar osj.main.MainClass

If at the route I have two folders:

/Applications
/Applications (Java)

and my script is in the "Applications (Java)" folder, then I always
end up in the Applications folder. At the same time if I call:

dirname "/Applications (Java)/MyApp/myapp.sh"

then this works as should.

Can anyone suggest a solution to my problem?

Andre


  Réponse avec citation
 
Page generated in 0,04891 seconds with 9 queries