Afficher un message
Vieux 18/08/2006, 19h53   #7
Xicheng Jia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: shell script to compare and delete files from a server???

Danish wrote:
> 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


If you just want to get the status instead of updating files, with the
full-featured 'rsync':
1) no need to transfer files, with the option -n or --dry-run
2) use ssh/key-pairs with option like -e "ssh -i /path/to/.ssh/id_dsa
user@host"
3) skip files based on checksum, not mtime/size with the option -c,
--checksum (MD4 with my current rsync version).
........
you may also want the option -av to return more info and then parse it.

Xicheng

  Réponse avec citation
 
Page generated in 0,06310 seconds with 9 queries