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

Stroller macmonster at myrealbox.com
Fri May 23 11:32:56 PDT 2008


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...

$ touch foo.sh bar.sh
$ echo '#!/bin/bash' > foo.sh
$ echo '#!/bin/bash' > bar.sh
$ echo 'echo "it worked!"' >> bar.sh
$ echo "./bar.sh" >> foo.sh
$ chmod +x *.sh
$ ./foo.sh
it worked!
$

In other words, the path to the current working directory is "./"

Stroller.



More information about the X-Unix mailing list