1

I have script that was provided with some SW. The script output is something like that (in debug mode).

+ changeDirectory
+ '[' -d /cdr/work/proc_raw/proc ']'
+ cd /cdr/work/proc_raw/proc
+ echo 'Changed to the directory: /cdr/work/proc_raw/proc'
Changed to the directory: /cdr/work/proc_raw/proc
+ retypeFileName
++ echo ''\''*.old'\'''
++ sed 's/'\''//g'
+ FILE='*.old'
+ case $TYPE in
+ compressFiles
+ echo 'files to compress: '
files to compress: 
+ find . -name '*.old' -mtime +3
./file1.cdr.old
./file2.cdr.old
...
+ find . -name '*.old' -mtime +3
+ xargs compress -f
+ ecode=0
+ '[' 0 -gt 0 ']'
+ echo 'executed: find . -name *.old -mtime +3 | xargs compress -f'

However, after that, when looking for the file1.cdr.old.Z, file1.cdr.old.Z, .. in that directory, the file is not there.

If to execute the file command, it seems that there is no reason for compress to fail:

-bash-3.2# file file1.cdr.old
file1.cdr.old: ASCII text, with very long lines

Any suggestions?

EDIT: the relevant parts from the script:

# Change to the selected directory
changeDirectory (){
    if [ -d $DIRECTORY ]
    then
    cd $DIRECTORY
    echo "Changed to the directory: $DIRECTORY" >> $LOGFILE
    else
        echo "$DIRECTORY does not exists" >> $LOGFILE
        exit 1
    fi
}

# Removes the "'" characters from filename.
retypeFileName (){
   FILE=$(echo $FILE | sed s/"'"//g )
}
# COMPRESSING FILES
compressFiles () {
   echo "files to compress: " >> $LOGFILE
   find . -name "$FILE" -type f $ACTION_TYPE +$PARAM >> $LOGFILE

   find . -name "$FILE" -type f $ACTION_TYPE +$PARAM | xargs compress -f
   ecode=$?

    if [ $ecode -gt 0 ]
    then
        dt=`date "+%Y-%b-%d %H:%M:%S"`
        echo "$dt > ERROR while compressing files. Error Code was $ecode" >> $LOGFILE
        exit 2
    fi

    echo "executed: find . -name "$FILE" -type f $ACTION_TYPE +$PARAM | xargs compress -f" >> $LOGFILE
}
user1977050
  • 409
  • 7
  • 18
  • Post the original script, not the debug output – daisy May 05 '13 at 09:57
  • sorry, I can't paste it all, but I'll paste the relevant parts of it – user1977050 May 05 '13 at 10:39
  • If you call compress file1.cdr.old, what happens? – Gilles 'SO- stop being evil' May 05 '13 at 23:07
  • Also what happens when you run commands such as locate compress or whereis compress. At this point I would be suspicious that compress is either not on the system or not on your $PATH. Also was this s/w run by someone else previously, and you're now running it? Perhaps compress is part of their environment but not yours. – slm May 06 '13 at 04:13

0 Answers0