Script stops working after copying it

Hi all,

When I cp a script, this section of the code stops reading from a file.

if [ -f ${BASEDIR}test.conf ]; then
   while read dirtoclean
   do
      DIRSTOCLEAN=${DIRSTOCLEAN}' '$dirtoclean
   done < ${BASEDIR}test.conf
fi

${DIRSTOCLEAN} doesn't return anything, even though it will work right before copying the script.

Even if I change the configuration file and create a new .conf, it still won't read from that file.

Any help or advice would be appreciated.

Thanks,
Nick

Did you copy the script to a new file in the same subdirectory or to a different subdirectory?

Is BASEDIR a relative or an absolute path?
By the way, the same can be accomplished by this command:

if [ -f "${BASEDIR}test.conf" ]; then
  DIRSTOCLEAN=$(cat "${BASEDIR}test.conf")
fi

I copied the file to the same directory as the original script.

---------- Post updated at 02:35 PM ---------- Previous update was at 02:29 PM ----------

Thanks. BASEDIR is a relative path that is set by this

BASEDIR=`echo $0 | sed -e 's/clean_reports.sh//'`

So the name of the second script is clean_reports.sh, or is that the name of the first script?

:wall:

It's the name of the original script. Forgot to change it after copying. That was the issue, it's working now. Thanks for the help.

OK, good. A universal command would be:

BASEDIR=${0%/*}/