$PATHTOSELF


Forum: Programming and Scripting
Topic: $PATHTOSELF
started by: Zucca

Posted by Zucca on Oct. 23 2006,01:34
Again again.. One simple Q. Bash scripting of course.  :;):

How to get path to currently running bash script?
Is there a predefined variable for it?

I need to make my script to run itself in some cases.

Posted by mikshaw on Oct. 23 2006,03:52
The built-in bash variable is $0
This returns the full path to the script, or to a link if a link was used to call the script.  In either case, though, it should work for most purposes.  The only place where I've seen a link be a problem is if the script has to cd into the directory containing the script.

Posted by Zucca on Oct. 23 2006,07:35
Ah. Of course.
I actually knew that, but never thought it as a path. =D
I just thought it as a script's name/the first command in the line.

Thanks anyways. :D

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.