Help with cp and mv in script

Hello,

I would like some help with a very basic script that I think should work but when from cron it doesn't. When ran manually it works fine. The script goes something like this

cd /wfmtransfer/import/agents/changed
for i in `ls -1 *.xml`
do
  [something] --this will create a .OUT file
  check=`grep Failure $i.OUT|wc -l`
  if [ $check -ge 1 ]
  then
    mv $i.OUT /wfmtransfer/imports/agents/Failure
    cp $i /wfmtransfer/imports/agent/Failure/originals
    cp $i /wfmtransfer/imports/agents/original_file
  else
    mv $i.OUT /wfmtransfer/imports/agent/Success
    cp $i /wfmtransfer/imports/agents/original_file
  fi
done

When the script runs from cron I get a copy in the original_file folder but nowhere else and I can't figure this out at all. Running the script manually works fine.

Any help would be greatly appreciated.

Thanks,
G

---------- Post updated at 05:52 AM ---------- Previous update was at 05:39 AM ----------

Its ok I figured it out

Typo i guess ... some missing "s":

...
 then
    mv $i.OUT /wfmtransfer/imports/agents/Failure
    cp $i /wfmtransfer/imports/agents/Failure/originals
    cp $i /wfmtransfer/imports/agents/original_file
  else
    mv $i.OUT /wfmtransfer/imports/agents/Success
    cp $i /wfmtransfer/imports/agents/original_file
  fi
...

No need to use ls. Filename generation works always in command line, not only with ls.
You can use grep exit status, no need to count output lines

cd /wfmtransfer/import/agents/changed
for i in *.xml
do
  [something] --this will create a .OUT file
  if grep Failure $i.OUT >/dev/null 2>&1
  then
    mv $i.OUT /wfmtransfer/imports/agents/Failure
    cp $i /wfmtransfer/imports/agents/Failure/originals
    cp $i /wfmtransfer/imports/agents/original_file
  else
    mv $i.OUT /wfmtransfer/imports/agents/Success
    cp $i /wfmtransfer/imports/agents/original_file
  fi
done