I downloaded a program, and it came with a shell script to execute it since it was written in Java. I made a symlink to the shell script on my desktop. Then I edited the script (in its real location), adding cd $(dirname $(readlink $0))
to the top to make it follow the symbolic link back to the original script to get the directory right, because the script needs to access files in its directory (e.g., the jar file).
The modification works if I execute the symlink from bash with the ./symlink.sh
command, but running it from my desktop environment causes it to say the main class could not be found, as if the cd
never actually occurred.
Is there some difference between having your desktop environment execute it versus executing it directly in bash that would cause this? I'm running Cinnamon as my desktop.
Further examination of the script shows that it is using $(dirname "$0")
to find the directory where it, and its associated files, are located.
echo $(dirname $(readlink $0)) > /tmp/dir-for-$$
to the script, run it in a shell and in the desktop environment, and tell us what the differences are in those two temp files? – Mark Plotnick Jun 9 at 22:09set -x
at the beginning of your script to see what is going on. – michas Jun 9 at 22:10