recursion

I'm using the UNIX csh and i wish to use recursion to nav my way up (or down as it is) a given folder.

My little test script is called "r" and takes a folder as argv[1] (or $1)

#!/bin/tcsh -f
set allFiles = `ls -A $argv[1]`
cd $argv[1]
while ($#allFiles)
if (-d $allFiles[1]) then
echo $allFiles[1]
# do whatever...
r $allFiles[1]
endif
shift allFiles
end

echo done.

however once it chages into a given dir the script "r" is no longer in the new dir and thus the process fails. I'm not the super user so I can not dump the script "r" in "bin". Can anyone help me do something similair?

Just use the absolute path of r.

instead of
r $allFiles[1]

use /full/path/name/r $allFiles[1]

That was r will always be found wherever you are. At the moment 'r' is only going to be found in the directory you are in.

Alternatively add the location of 'r' to your PATH. Same effect as putting it in bin - the reason that you could find it if it was in bin (regardless of where you are) is that bin is in your path......same logic.