The UNIX Forums
"Join the Network of UNIX System Users"


 
brynrees
Newbie
Rank: 1



UID 78
Digest Posts 0
Credits 0
Posts 26
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 6, 2007 09:26 AM  Profile | P.M. 
diff



diff



hi all,


i want to do this shell script.

create a script that will check the transferred file vs. orig file.
1. diff the file1 and file2
2. if difference found, retain the original file and email to netcracker team.
3. if no difference found, delete the previous file and retain the new 1.


Top
Hopper
Newbie
Rank: 1



UID 176
Digest Posts 0
Credits 0
Posts 58
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 6, 2007 09:27 AM  Profile | P.M. 
code:
/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.
Top
CYBERAY
Newbie
Rank: 1



UID 102
Digest Posts 0
Credits 0
Posts 73
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 6, 2007 09:27 AM  Profile | P.M. 
thanks,

it's working now. i just want to add some checking.

1. if $f_name does not exists,
call the script and it still problem, call again (10x).
Top
d16man
Newbie
Rank: 1



UID 104
Digest Posts 0
Credits 0
Posts 52
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 6, 2007 09:27 AM  Profile | P.M. 
this should take care of it:


code:

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
Top
 

 

All times are GMT, the time now is Jul 31, 2010 03:28 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.006001 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP