progpath='/bin/ksh -c "whence $0"'
This command does not work. The problem is, that we do not use ksh at
this place (not installed, and I won't dare to try, unless you tell me
otherwise..). The context of the command clearly reveals the intention
of it, i.e. to get the path of the run script.
Do you guys know an alternative command (available in sh/csh/bash)?
I'd prefer not to code an absolute path into the script...
Best regards,
Kenneth
But is not correct. $0 shouldn't be looked up in $PATH unless it
can't be found in the current directory.
If your /bin/sh is a Unix conformant shell, try:
progpath=$(
progpath=$0
case $0 in
(*/*) ;; (*)
[ -e "$progpath" ] || progpath=$(command -v -- "$progpath") || exit
esac
cd -P -- "$(dirname -- "$progpath")" && pwd -P || exit
) || exit
progpath=$progpath/$(basename -- "$0")
The above doesn't work if the dirname or basename of $0 ends in
a newline character.
--
Stéphane
> If your /bin/sh is a Unix conformant shell, try:
>
> progpath=$(
> progpath=$0
> case $0 in
> (*/*) ;; (*)
> [ -e "$progpath" ] || progpath=$(command -v -- "$progpath") || exit
> esac
> cd -P -- "$(dirname -- "$progpath")" && pwd -P || exit
> ) || exit
> progpath=$progpath/$(basename -- "$0")
>
> The above doesn't work if the dirname or basename of $0 ends in
> a newline character.
Thanks mate. I will implement this and hope it works. Thanks for your
effort - it's appreciated :)
/Kenneth