file size comparision local file and remote file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting file size comparision local file and remote file
# 1  
Old 11-13-2008
file size comparision local file and remote file

Hi,

I have written a script which would FTP a dump file to the FTP server and log the whole activity into a file. to confirm the success of the file copy i grep for "226 file receive OK" and then send out an email saying success. Now i want to make sure the bytes of the local file and remote file are the same.

i read on the forum that we can do an ls -l on the local and remote files and compare the two..

Upon my research i couldn't find a statement which will extract the bytes from a FTP file and put that into a variable so that i can compare...

Need some help with that.
# 2  
Old 11-13-2008
Hi,
how about using wget (or Your ftp method), to read the file back again, with another name, and then diff them? For example if ASCII/CRLF conversion could mess thing up...

/Lakris
# 3  
Old 11-13-2008
thanks for the reply Lakris...

i did a
result=`ssh user@<hostname> ls -l <filename> | awk '{print $5}'`

this gave me the size in bytes . This fits my requirement.
# 4  
Old 11-13-2008
Great, np,
You could also try

result=$(ssh user@<hostname> stat -c%s filename)

to avoid problems with different formats of ls (LOCALE and such stuff)

/Lakris

PS AND to avoid awk, since I'm just too bad at it Smilie
# 5  
Old 11-13-2008
something new. i will try that...
thanks Lakris...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File transfer from remote to local

Hi, I came across the scenario, that I need to copy files from the remote server to my local. The files in the remote server are created by another job and its keep on generating the files in that remote folder. We can't able to use SCP command and we're using SFTP to connect the server and... (3 Replies)
Discussion started by: Janarthan
3 Replies

2. UNIX for Dummies Questions & Answers

Transfer image file from local to remote with sftp

Hi. I have managed to transfer a file from remote to my raspberry pi, but I have the camera mounted on the Raspbien so I would like to transfer the image the other way. I use this line: sshpass -p 'PASSWORD' scp -- USER@ssh.servername.com:/www/cam/image.jpg /home/pi/shared/web/image.jpg (4 Replies)
Discussion started by: brickglow
4 Replies

3. UNIX for Dummies Questions & Answers

File listing from remote to local directory

Hello, I have a file at remote server. I have to select only current day's files that are dropped on ftp server. The files do not have date or timestamp on them. so I plan to get the file listing from remote server to the local server. Based on file listing date I can find out when the files... (2 Replies)
Discussion started by: pavan_test
2 Replies

4. HP-UX

How to execute a remote file with local command

Hello, I know this is somewhat strange, but please let me know if possible. I want to execute a program file in the remote machine with command on the local machine. Let me make things more clear. Suppose I have a cc on my local system and do not have that on the remote system. I want to use... (2 Replies)
Discussion started by: Veera_Raghav
2 Replies

5. Shell Programming and Scripting

Calculate the time difference between a local file and a remote file.

I m stuck with a issue. I need to calculate the time difference between two files.. one on the local machine and one on the remote machine using a script. Can any one suggest the way this can be achevied Thanks, manohar (1 Reply)
Discussion started by: meetmano143
1 Replies

6. UNIX for Dummies Questions & Answers

File System - Remote or Local??

Is there a way to find if the file systems mounted on a AIX/Linux box is local or remote? (1 Reply)
Discussion started by: Un1xNewb1e
1 Replies

7. UNIX for Dummies Questions & Answers

how to mount a file system of a remote machine to local file system

Hi friends, In my case, there are serveral PCs running Linux in a LAN. I would like to to mount the directory /A_river of machine-A to the file system of another machine machine-B so that I can access files in that directory. I do not know how to do this. The situation is complicated by... (2 Replies)
Discussion started by: cy163
2 Replies

8. UNIX for Dummies Questions & Answers

how to find whether a file is local or remote file?

Is there any system call to find whether a file is local or remote?? Thanks in advance!! -Jack Fds (3 Replies)
Discussion started by: jackfds
3 Replies

9. UNIX for Dummies Questions & Answers

file size in bytes is different in ftp and local pc

Hi how can it be that say i have text (xls) file that is 661 bytes when i upload it to Solaris ftp its becomes 650 byes and when i downloading it back its again 661 bytes both in my local pc and Solaris ftp the file remains not corrupted and valid (2 Replies)
Discussion started by: umen
2 Replies

10. Solaris

[FTP]opying of file from remote to local machine

Hi All, i wannna copy a file from the remote machine to my local machine using FTP protocol. i have made a connection to the remote machine , then i used the "get" cmd to copy the remote file as below :-> ftp> get (remote-file) /home/aruba/opmtools/was50/Was5Install.doc (local-file)... (1 Reply)
Discussion started by: sonbag_pspl
1 Replies
Login or Register to Ask a Question