Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking the bundle of files after ftp 1

Status
Not open for further replies.

adaaje

Technical User
May 26, 2006
60
AU
Hi guys,

I have the number of files and I need to check the files before transfer via ftp and the files after transfer, whether there is any file missing via transfer or not.

Because the way it's transfer from the system is file by file, it doesnt tar it or zip it first. So, some kind a "mput *" command

So, obviously it's gonna deal with two hostname, but our script is gonna be in one hostname which is in destination server.

Do you guys have any idea about this pls ?

Greatly appreciated,

thx
 
Just generate a listing from the local and remote host and [d]diff[/b] them perhaps?

If you want to make sure the contents are identical you may want to generate a long listing and compare file sizes... and if you want to be really sure you could generate sum, cksum or md5sum listings and compare them?

Annihilannic.
 
Hi Annihilannic,

Thx for your input, I know using "diff", but I've got a few more question.
how do I generate a listing in remote host in scripting which is in local host and compare it with directory in local host?
normally I access to remote host using ssh,
so "diff dir1 [how to directory remote host]"

And using "diff" just tell the content of file1 and file2. How if I wanna tell any particular word/line in file is missing after comparing both files ?

Using "diff file1 file2" the result is :
Code:
1,13c1,11
total 10
drwxr-xr-x   2 1003     everyone        0 Jun  7 17:46 Script
-rw-r--r--   1 1003     everyone       50 Jun  1 19:15 banyak.txt
-rw-r--r--   1 1003     everyone       50 Jun  6 22:02 baru.txt
-rw-r--r--   1 1003     everyone       54 Jun  6 21:49 barulagi.txt
drwxr-xr-x   2 1003     everyone        0 Jun  8 21:30 dalem
-rw-r--r--   1 1003     everyone      221 Jun  1 18:28 flat.txt
-rw-r--r--   1 1003     everyone      113 Jun  1 21:58 html.txt
-rw-r--r--   1 1003     everyone       32 Jun  7 17:52 kucing.awk
-rw-r--r--   1 1003     everyone       34 Jun  1 19:12 lagi.txt
-rw-r--r--   1 1003     everyone       65 Jun  1 22:09 subject.txt
-rw-r--r--   1 1003     everyone       80 Jun  6 23:06 test.txt
-rw-r--r--   1 1003     everyone       65 Jun  7 17:21 testlagi.txt
---
total 8
drwxr-xr-x   2 1003     everyone        0 Jun 12 11:47 Script
-rw-r--r--   1 1003     everyone       50 Jun 12 11:47 banyak.txt
-rw-r--r--   1 1003     everyone       50 Jun 12 11:47 baru.txt
-rw-r--r--   1 1003     everyone       54 Jun 12 11:47 barulagi.txt
drwxr-xr-x   2 1003     everyone        0 Jun 12 11:47 dalem
-rw-r--r--   1 1003     everyone      221 Jun 12 11:47 flat.txt
-rw-r--r--   1 1003     everyone      113 Jun 12 11:47 html.txt
-rw-r--r--   1 1003     everyone       32 Jun 12 11:47 kucing.awk
-rw-r--r--   1 1003     everyone       34 Jun 12 11:47 lagi.txt
-rw-r--r--   1 1003     everyone       65 Jun 12 11:47 subject.txt

Thx man in advance
 
yes, I do have ssh access.

Cheers
 
Something like:

[tt]cd /source/dir ; sum * > /tmp/localfiles
ssh remotehost 'cd /destination/dir ; sum *' > /tmp/remotefiles
diff /tmp/localfiles /tmp/remotefiles[/tt]

Annihilannic.
 
Thx Annihilannic,

I understand about this, but what about if I wanna compare directory in directory recursively, because using your command is just only compare files in directory

Here's the result :
Code:
sum: Script: Is a directory
sum: dalem: Is a directory
sum: Script: Is a directory
sum: dalem: Is a directory
3a4
> 38511     1 beda

Thx man,
 
Hmm... something like this perhaps (not tested much)?

[tt]find /source/dir -tyep f | xargs sum | sed "s#/source/dir##" > /tmp/localfiles
ssh remotehost 'find /destination/dir -type f | xargs sum | sed s#/source/dir##"' > /tmp/remotefiles
diff /tmp/localfiles /tmp/remotefiles[/tt]

The seds are in there to take out the directory names which may differ on the remote and local hosts... no need to do that part if the directory structure is identical too.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top