Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: $PATHTOSELF< Next Oldest | Next Newest >
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Oct. 23 2006,01:34 QUOTE

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.


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Oct. 23 2006,03:52 QUOTE

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.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Oct. 23 2006,07:35 QUOTE

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


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
2 replies since Oct. 23 2006,01:34 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: $PATHTOSELF

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code