Retrieving file size in a remote server using SSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Retrieving file size in a remote server using SSH
# 1  
Old 02-21-2014
Linux 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 remote server
1>change the directory where file is(known to me).
2>get the size of file
Using below command I able to get the file but “stat -c%s” retunes empty.

ssh -q -o ControlPath=/home/kraut/.ssh/cm_socket/%r@%h:%p_13929 uname@ip 'find /home/tmp/incoming/history/ -name user_HIST_151112_222225 -exec stat -c%s {} \;


please suggest me the solution on this or any other way to verifying successful file delivery on remote server.
# 2  
Old 02-21-2014
Quote:
Originally Posted by ketanraut
Hi,



ssh -q -o ControlPath=/home/kraut/.ssh/cm_socket/%r@%h:%p_13929 uname@ip 'find /home/tmp/incoming/history/ -name user_HIST_151112_222225 -exec stat -c%s {} \;

Here you seemed to have missed the second single quote for find. Its not closed.

You can also try it this way:
Code:
ssh -q -o ControlPath=/home/kraut/.ssh/cm_socket/%r@%h:%p_13929 uname@ip 'ls -l /home/tmp/incoming/history/user_HIST_151112_222225' | awk '{print $5}'

This User Gave Thanks to chacko193 For This Post:
# 3  
Old 02-24-2014
..thats working fine! thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to check via SSH and credentials if file on remote server exists?

Hi there, I am sorry to ask that kind of beginner thing, but all the code I found online didnt work for me. All I want to do is: Check via SSH if a File exists on my webserver. The SSH login has to be with username and password. So I would be very thankful if somebody could write the line.... (8 Replies)
Discussion started by: Jens885544
8 Replies

2. UNIX for Beginners Questions & Answers

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... (2 Replies)
Discussion started by: abhi_123
2 Replies

3. Shell Programming and Scripting

Multi server access through remote server using ssh

Team, Presently I have 5 ip address kept in ip_abc1 file, for each of the ip address listed, i need to login on each ipaddress one at a time and login as below for that specific ip address ssh -p 8101 karaf@<ip.address_for the specific ip address as logged in> password features:list... (4 Replies)
Discussion started by: whizkidash
4 Replies

4. UNIX for Advanced & Expert Users

Unable to ssh to remote server

Hi, I have two SunOs sparc servers mac1 and mac2. I have exchanged keys between them inorder to passwordless login ssh from mac1 to mac2. However, it is failing after authentication. Part of the debug is as below. Please suggest whats wrong and how do i fix that!! Note: i do not have... (1 Reply)
Discussion started by: mohtashims
1 Replies

5. Shell Programming and Scripting

Script to ssh to remote server

Hi All, I need to prepare a script. Description: Currently i am in server "x(ubuntu os)", here i need to develop a script to ssh to another server "y(ubuntu os)", i have password less authentication to "y". i have done the below #!/bin/bash #ssh to the server "y" and confirming i am... (2 Replies)
Discussion started by: kumar85shiv
2 Replies

6. Shell Programming and Scripting

ssh to remote server and check if file exists

Hi everyone, I am trying to figure out a way to ssh to remote server and check if file exists, and if it doesn't I want to leave the script with an exit status of 5. I have the following that I am attempting to use, but it is not returning anything: check() { ssh ${SOURCE_SERV} "ls -l... (4 Replies)
Discussion started by: jimbojames
4 Replies

7. 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

8. Shell Programming and Scripting

ssh text into file on remote server

Hello, I have about 90 servers that I need to update snmp configs. I am trying to write a script that will echo 4 new lines of text into the snmpd.conf file. I have tested it locally and it works when the server ssh into itself but when I try to run the script to ssh into a remote server it logs... (5 Replies)
Discussion started by: mr_dthomas
5 Replies

9. Shell Programming and Scripting

SSH Remote Server issue

I have a script that connects to remote servers using a public key. Some of the servers are not set up for the public key and I receive the following when I attempt to ssh: The authenticity of host 'XXX' can't be established. RSA key fingerprint is... (1 Reply)
Discussion started by: la_womn
1 Replies
Login or Register to Ask a Question