odd recursion: calling "by hand" vs calling by cronscript...
I have a cronscript which checks (then fixes) users directories for badly named files - meaning I don't want to allow spaces or ampersands in file or directory names & it will replace spaces with underscores and removes ampersands.
If I have a directory uploaded by a user like this:
/var/pub/ftp/username/top level/second level/third level/
/var/pub/ftp/username/top level/second level/third level/pork & beans
then I call this script by typing it's name (I call it sr) in a bash shell like this:
then I end up with:
the program works by parsing directories then recursively calling itself to descend further until it has fix all files and directories below the directory it has been called.
I set it to run in a cronscript, and get different results! Here is what I get when it is called by cron:
/var/pub/ftp/username/top_level/second_level/third level/pork & beans
so, it doesn't successfully call itself when started by cron.
Here is the script for sr (called that originally for space replace)
and if you can give me a hint why this might be happening, I would be very grateful.
I just don't get why the recursion works when typed into bash, but not when called by cron
Running FC2, btw.
The cronjob belongs to root.
for i in *
if [ -d "$i" ] # if * is a directory
cd "$i" # descend into the directory
for y in *
tempa=$(echo $y | sed 's/ /_/g' | sed -e 's/\&//g' | sed 's/__/_/g')
if [ "$y" != "$tempa" ]
mv "$y" "$tempa"
if [ -d "$tempa" ] # if this is also a directory, call this program
sr # this is the name of THIS program, must be in your PATH
tempa=$(echo $i | sed 's/ /_/g' | sed -e 's/\&//g' | sed 's/__/_/g')
if [ "$i" != "$tempa" ]
mv "$i" "$tempa"
Thanks for you help,
Paul in Colorado
Last edited by prx; 02-12-2005 at 11:28 AM.