Grep command is not working when put into cron

Hi,

I worte a script which runs perfect when i execute it manually. But when i scheduled into cron the grep command alone is not working.

the sample script,

/usr/bin/grep FTP $subfile > /tmp/tfsrec.dat
tfs=`echo $?`
if [ $tfs = "0" ]
then
echo "FTP FOUND"
else
echo "FTP NOT FOUND"

Where FTP is a string in a set of files which is huge size. Please help me out.

is this your complete script?

could you list the error that you are seeing?

Try something like:

#!/bin/sh

subfile=.....

# other lines....
# .....

/usr/bin/grep FTP "$subfile" > /tmp/tfsrec.dat
tfs=`echo $?`

case "$tfs" in
  0)    echo "FTP FOUND"
    ;;
  *)    echo "FTP NOT FOUND"
    ;;
esac

Regards

Cron standard output and error output is mailed to your user mailbox. So please check mail command. It is possible to redefine it.

no this is not my complete script. The orginal script is very big. I didnt get any error while putting the script in cron, but the grep condition is not working. For the files which doesnt have the string "FTP" also it displays as FTP FOUND. Not Sure still whats the problem.

Franklin52 thanks for the alterante method. I will try it out and post you the result.

gbielanski let me check the mails and post you.

Do we have any powerfull command other than "grep" ?? Caz, the size of files in which itz looking into is in GB's. It may check nearly to some 100 files for a particular string FTP.

And tat too the word count of the file is zero. Please help me out.