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

Stroller macmonster at myrealbox.com
Fri May 23 12:38:12 PDT 2008


On 23 May 2008, at 19:55, Eric F Crist wrote:
> On May 23, 2008, at 1:32 PM, Stroller wrote:
>> On 23 May 2008, at 15:21, 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...
>>
>> ...
>> In other words, the path to the current working directory is "./"
>>
>> Stroller.
>
> His current working directory may not be . relative to the  
> directory his script and tool reside in.  I think that's the rub.   
> dirname $0 I think is his best solution, aside from having his  
> friend possibly put his script and/or tool somewhere within their  
> PATH.

Doh! Excuse me.

You're quite right that dirname is the right way to do it. I don't  
know why I was incapable of grokking your replies before I posted  
myself.

Stroller.



More information about the X-Unix mailing list