[CentOS] Autorun ability on cd?

Wed Aug 5 20:37:36 UTC 2009
James B. Byrne <byrnejb at harte-lyne.ca>

On: Wed, 5 Aug 2009 10:15:47 -0400, Stephen Harris
<lists at spuddy.org> wrote:
>
> Untested, and it depends very much on your shell, but create a
> function
>
>   cdr()
>   {
>     cd $1 || exit
>     if [ -x ./.myscript ]
>     then
>       ./.myscript
>     fi
>   }
>
> Now if you use "cdr" (for Change Directory & Run) it should do what
> you want (runs a file called ".myscript" in the new directory if
> it exists)
>
>
> This _might_ work...
>
>   cd()
>   {
>     command cd $1 || exit
>     if [ -x ./.myscript ]
>     then
>       ./.myscript
>     fi
>   }
>
> OK, I just tested the later under ksh88 and it worked.  You'd need
> to
> test with bash/ksh93/whatever-your-shell-is
>
>   $ cat x1/.myscript
>   echo hello
>   $ cd x1
>   hello
>   $ mkdir x0
>   $ cd x0
>   $ cd ..
>   hello
>   $
>
> As you can see, everytime I enter the "x1" directory it runs
> .myscript
>
> --
>
> rgds
> Stephen
>******************
>

Thank You. I usually run in the CentOS default (bash) shell.  I will
give this a try and report back.

Many thanks,


-- 
***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3