Ubuntu 10.04, Launcher, $PWD…

Johnny Rosenberg gurus.knugum at gmail.com
Thu Dec 27 20:53:48 UTC 2012


I wrote a script for my wife, who still runs Ubuntu 10.04 (it's still
supported, you know…). To make it easy to run the script, I created a
launcher for her desktop, but it didn't work. The reason is that the
script uses some files located in the same folder as the script
itself. I thought that PWD is the location in which the script starts.
The script works when started directly, but not when started from the
launcher.

The launcher is located at her desktop (~/Skrivbord – this is a Swedish setup).
I changed the script to view the PWD variable, and it displayed ~/,
NOT ~/Skrivbord and NOT the folder in which the script is located.

Is there a way to get around this, except to hard code the path? I
want it to work no matter in which folder the script and its files are
located, as long as they are located in the same folder. I shouldn't
need to change the path variables in my script every time I ”install”
the script on a different machine. Is there another environment
variable that is more suitable in this case? Or another method?


Johnny Rosenberg




More information about the ubuntu-users mailing list