Check the size of the file on different server

Hello,

I have two servers A and B, My script is written on Server A. I am picking up the file say "abc.txt" from Server B using sftp command and putting it in a directory at Server A.

Now the catch is, If the file size of "abc.txt" is greater thn the available size on Server A, thn an email should be sent with the error msg.

question::
1) How to check the size of the file "abc.txt" from server A. I tried ls -ltr abc.txt on ftp prompt but its not working

Please Help

Thanks in advance

IS the remote server windows or unix?

Do you mean ftp or sftp you mention both?

remote server is Unix.

i am usind sftp command to get the file but tried to get the file size using ftp also.

If you use sftp, then ssh is likely to work, too? Then just do

ssh name@B.remote.net stat -f "%z" /location/of/large/file

As you are using SFTP, you can check file size of "abc.txt" before getting the file from server B using below command in sftp prompt.

! can be used in sftp prompt to execute local commands.Now fs.txt file created on server A contains file size.
Note: I have tested this in Solaris.
-Nithin.

My script is written on server A and we are picking up the file from B to A.

Now when i am connecting to server B from A using sftp:

A-sftp> If i write !, in this case i will get the size of files on local server A, but i want the size of the file which is located on server B. So that i if the file size is big, i won't import it to server A

I am using AIX version 4.3.3.0

Thanks For your help.