bash - Script works from command line but not from a command in Application Finder Launcher - Ask Ubuntu


i've written bash script found @ directory:

/home/harmelodic/.jetbrains/clion.sh 

that performs following:

#!/bin/sh  ./clion*/bin/clion.sh 

this run clion.sh script found at:

/home/matthew/.jetbrains/clion-2016.2.3/bin/clion.sh 

if open terminal in /home/harmelodic/.jetbrains/ , perform:

$ ./clion.sh 

it runs , opens clion ide.

however, if use launcher application finder perform command execute script (as shown below), clion ide fails open.

enter image description here

i'm stumped. thought command input run script fine doesn't.
i've ensured script executable , runs via terminal refuses run via launcher found in application finder.

why, , how fix this?

well, had pebcak error...

i mistakenly thought if ran script, script automatically know , use it's current location relative path.
not case, turns out. script treat whatever location user running script path use when referring relative paths.

meaning if went /home/harmelodic/ , ran:

$ ./.jetbrains/clion.sh 

the script fail /clion*/bin/clion.sh in:

/home/harmelodic/ 

instead of

/home/harmelodic/.jetbrains/ 

the solution current directory of script , perform command using current directory combined relative path mimic relative path whilst using absolute paths:

#!/bin/sh  current_dir=`dirname $0`  $current_dir/clion*/bin/clion.sh 

this works directory, meaning works within launcher application finder.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User