[X-Unix] Shell Script: How get parent path to invoke a sister tool?

Eric F Crist ecrist at secure-computing.net
Fri May 23 07:28:07 PDT 2008


On May 23, 2008, at 9:21 AM, Jerry Krinock wrote:

> I want to ship someone a directory containing two files: a shell  
> script and a tool.  Within the shell script, I'd like to invoke the  
> tool.  And I want it idiot-proofed to work regardless of where the  
> user drops my directory.
>
> So, I need the path to the tool within the script.  It seems like a  
> bash shell script should have an environment variable available  
> giving the path to it's own parent directory, but I don't see any  
> such thing in printenv output.
>
> How can I do this?


Jerry,

Simply require that the tool which is called be within the same  
directory as the script.  From there, you can figure out you current  
working directory, or simply call the tool with ./tool_name.

Hope this helps.
-----
Eric F Crist
Secure Computing Networks




More information about the X-Unix mailing list