Get the remote server file size in UNIX


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Get the remote server file size in UNIX
# 1  
Old 08-10-2017
Get the remote server file size in UNIX

Hi All,

I am trying to sftp, get a file from remote server.
Post this we need to check the remote server file size or checksum value of the remote server file and compare it with the file size in the current server.

But I am facing issue to get the remote server file size. Could you please help me on this.
System: Sun OS 5.10
I have tried below approaches but is not working out:

1)
Code:
 sftp user@hostname << EOF
ls -l filename > filesize.txt
get filesize.txt
EOF

Gives error as couldn't stat remote file: No such file or directory

2)
Code:
ssh user@hostname "ls -l filename"

Doesn't give output as the unix prompt doesn't come back and need to kill the connection.

Could you please help me on this.

Thanks

---------- Post updated at 11:48 AM ---------- Previous update was at 09:41 AM ----------

I have resolved using below:

Code:
sftp user@hostname << EOF>/path/remote_size.txt
ls -l filename
EOF

# 2  
Old 08-10-2017
Thanks for letting us know you solved by yourself and mostly, gave your solution Smilie
# 3  
Old 08-10-2017
Why do you need to compare file sizes? I'd be surprised if sftd didn't reflect a failure in its exit code.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Do I require remote login access to a windows server to transfer files from a UNIX server

Hi All I need to transfer a file from a UNIX server to a windows server. I saw that it is possible to do this using scp command by looking at the forum listed below: ... (2 Replies)
Discussion started by: vx04
2 Replies

2. Shell Programming and Scripting

Retrieving file size in a remote server using SSH

Hi, I have public and private keys and that's works fine for me. now I am sending files one by one on remote server and I want to check is file successfully delivered or not by comparing size of file on local machine and remote server using ‘stat -c%s'. Below operations need to be done on... (2 Replies)
Discussion started by: ketanraut
2 Replies

3. Shell Programming and Scripting

FTP using script not working (for transfering file from a remote unix server to windows PC.)

hi, Im using the following code for FTP #!/usr/bin/ksh ftp -v -n "10.29.45.11" << cmd user "mahesva" "mahesva123" get rtl.tar quit cmd Below is the log when i run the above code ********************************** Connected to 10.29.45.11. 220 (vsFTPd 2.0.1) 530 Please login with USER... (20 Replies)
Discussion started by: dll_fpga
20 Replies

4. Shell Programming and Scripting

SFTP - Get size of file on remote server

Hi, I have a requirement where I need to do SFTP connection to remote server, get the size of the file on remote server and depending on the size, i need to get the file onto local server. Is there any command in SFTP to get the size of the file. I found one in FTP but not in SFTP (2 Replies)
Discussion started by: forums123456
2 Replies

5. Shell Programming and Scripting

Deleting a file from REMOTE Unix Server

Hi All, I have a requirement where i need to remove a file from Remote system. Can any one suggest me how to do this? My requirement is, i need to archive the file in a separate system. If the remore system is having files older than 7 years, then i need to delete that files from the remote... (2 Replies)
Discussion started by: Raamc
2 Replies

6. UNIX for Advanced & Expert Users

Commands to copy a tar.gz file from a Remote Unix Server to Local Desktop.

Hi, Just wanted to know, how can I ftp/transfer/copy a (design.tar.gz) archive from a Unix Server (sdmc222.sdmc.cp-srv.com) which is at a remote location, to my Windows Desktop. Obviously, it is not possible at cmd prompt on my Windows using the following commands :- ftp... (3 Replies)
Discussion started by: marconi
3 Replies

7. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies

8. Shell Programming and Scripting

Transfer file from local unix server to remote server

want to remove this thread. thanks (2 Replies)
Discussion started by: indira
2 Replies

9. HP-UX

Transfer file from local unix server to remote server

want to remove the thread thanks (2 Replies)
Discussion started by: indira
2 Replies
Login or Register to Ask a Question