hi all,
i want to do this shell script.
create a script that will check the transferred file vs. orig file.
- diff the file1 and file2
- if difference found, retain the original file and email to netcracker team.
- if no difference found, delete the previous file and retain the new 1.
/usr/bin/diff $F_PATH/$F_NAME1 $F_PATH/$F_NAME2 >> /dev/null 2>&1
if [ $? -eq 0 ]
then # NO CHANGE
rm $F_PATH/$F_NAME1
else # CHANGE
rm $F_PATH/$F_NAME2
uuencode $F_PATH/$F_NAME1 $F_NAME1| mailx -s "$F_NAME1 CHANGED" $NC_EMAIL
fi
That should do basically what you need it to, unless I misunderstood the requirements.
You'll need to add the file transfer bits above that block yourself.
Thanks,
it's working now. i just want to add some checking.
- if $F_NAME does not exists,
call the script and it still problem, call again (10x).
This should take care of it:
for x in 1 2 3 4 5 6 7 8 9 10
do
### FILE TRANSFER CODE ###
### SHOULD BE PLACED HERE ###
if [ -f $F_NAME1 ] # TESTS TO SEE IF FILE 1 EXISTS
# -s WOULD CHECK FOR EXISTANCE AND SIZE > 0
then
/usr/bin/diff $F_PATH/$F_NAME1 $F_PATH/$F_NAME2 >> /dev/null 2>&1
if [ $? -eq 0 ]
then # NO CHANGE
rm $F_PATH/$F_NAME1
break
else # CHANGE
rm $F_PATH/$F_NAME2
uuencode $F_PATH/$F_NAME1 $F_NAME1| mailx -s "$F_NAME1 CHANGED" $NC_EMAIL
break
fi
else
sleep $SLEEP_INT # INTERVAL TO SLEEP IN SECONDS
fi
done