Re: shell script to compare and delete files from a server???
Jon LaBadie wrote:
> Danish wrote:
> > Danish wrote:
> >> Hi,
> >> I just got this script to write from my boss, but I thought I should
> >> discuss my problem here too.
> >>
> >> Ive got this situation where:
> >> 1) There are 2 server's ( A & B) located at quite a distance from each
> >> other..
> >>
> >> 2) Only B can access A using the shell. A cannot access B.
> >>
> >> 3) There is a perl script on B which runs every hour. It downloads
> >> certain files from another remote server using ftp. When these files
> >> have been downloaded comepletely they are 'scp'd to A using a shell
> >> script.
> >>
> >> Now I have been told to:
> >> 1) Make a shell script in B, to compare, whether the downloaded files
> >> in B have been completely 'scp'd to A.
> >> 2) When the comparing has been done, giving a result that the files are
> >> same on both the servers, the script then should delete the downloaded
> >> files from B
> >>
> >> Frankly speaking, I am confused as to how to go about comparing the
> >> files...
> >>
>
> presumably you have a list of files on B that supposedly were
> already uploaded to A. Use that list to generate "checksums"
> of each of the files on each host. Compare the checksums and
> if they match, the files on the two systems are identical.
>
> You really should also do this on the original source host,
> before it gets to B to ensure the file has been received on
> B accurately before uploading to A.
>
> Programs that do checksums include sha1sum, md5sum, cksum.
>
> The files on A can be determined with ssh from B:
>
> ssh A sha1sum file1 file2 file3 ...
I spoke to my boss regarding the checksum, but he does not want it that
way...So ill have to think of some other way
Danish
|