Sunday, January 10, 2010

Welcome And Greeting For A Church

How to determine the execution path of a script in BASH



This weekend I was looking for ways to make a BASH script that works as a pitcher for the Oriole and needed to know the execution path itself script.
For a moment I did not know how, but The Great Totuma enlightened me and I remembered the basic parameters of any script ... it was then when he came to my mind the famous
$ 0
.

$ 0 contains the full path of running script. This parameter, along with another little program will allow us to do the magic. Application

dirname for more information.)
What we do is pass dirname $ 0 and then concatenate the name of any program / script and voila! We will have our automatic launcher. Would something like

# / usr / bin / bash
CWD = $ (dirname $ 0)
sh $ CWD / otro_programa.sh



0 comments:

Post a Comment