Checking integrity copied from remote server using UNIX command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking integrity copied from remote server using UNIX command
# 1  
Old 11-21-2016
Checking integrity copied from remote server using UNIX command

I am getting a file (abc.txt) using scp from remote server.
Code:
scp <connect string> -i $HOME/.ssh/id_dsa rem_id@hostname:/var/prod/abc.txt /var/prod/abc.out

Before loading I need to check if the file is indeed same , for that I thought of checking the line count but when I used ssh command it was prompting for password.
Is there any other method to check integrity?

Basically we load it in a table and we need to ensure record loaded matches with the the one present in file.

Last edited by rbatte1; 11-21-2016 at 11:38 AM.. Reason: Changed ICODE to CODE tags and corrected spelling
# 2  
Old 11-21-2016
scp and ssh - for the same user - should use the same authentication method, so I can't see why ssh needs a password when scp doesn't.

Why can't you copy the file and then do the check?
# 3  
Old 11-21-2016
Quote:
Originally Posted by RudiC
scp and ssh - for the same user - should use the same authentication method, so I can't see why ssh needs a password when scp doesn't.

Why can't you copy the file and then do the check?
steps are as below
  1. check the cksum on remote server
  2. copy the file on local server '
  3. check the cksum on local server and it should match

Ok let me check why ssh is not working

---------- Post updated at 06:36 AM ---------- Previous update was at 05:16 AM ----------

Quote:
Originally Posted by RudiC
scp and ssh - for the same user - should use the same authentication method, so I can't see why ssh needs a password when scp doesn't.

Why can't you copy the file and then do the check?
Hi it seems to able to connect and run the command , however in the file I get count as well as file name , is there way I can put some thing like count separator with only file name (not full path) and last modified date of remote server

Code:
 ssh id@hostname  'wc -l /var/uat/a.ctl ' > abc.txt
 cat abc.txt
1 /var/uat/a.ctl


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by rbatte1; 11-21-2016 at 11:40 AM.. Reason: RudiC Added CODE tags; rbatte1 converted text list to formatted numbered list
# 4  
Old 11-21-2016
Counting the number of lines isn't much of a check that the files are really the same - use an actual checksum (e.g. cksum or md5sum).

Something like:
Code:
scp -i $HOME/.ssh/id_dsa rem_id@hostname:/var/prod/abc.txt /var/prod/abc.out
diff -q <(ssh -i $HOME/.ssh/id_dsa rem_id@hostname 'cksum < /var/prod/abc.txt') <(cksum < /var/prod/abc.out)

should exit with 0 if the checksums are identical.

(<(stuff) is bash process substitution, but you could use temporary files instead. Feeding cksum from stdin rather than a file means you don't need to care what the filename is.)
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. UNIX for Dummies Questions & Answers

Checking files in remote server and decide to copy file or not

Hi there, I have a problem in my script, I need to check whether file exists in remote server or not, if the file exists, then stop copy else copy the file to the server.. my code is something like this while read $server do if ssh $server "cd $directory_name; if ; then echo "Error:... (2 Replies)
Discussion started by: beezy
2 Replies

3. Shell Programming and Scripting

Check files copied from remote server

There is a process which copy files form unix a to unix b I would like to check whether all files copied from a to b or not ,and list which are the missing files. Is there a command to check like that (3 Replies)
Discussion started by: lalitpct
3 Replies

4. Shell Programming and Scripting

preserving the timestamp of a file when copied from remote server to local server using ftp

Hi, I need to copy few files from remote server to local server. I write a shell script to connect to the remote server using ftp and go to that path. Now i need to copy those files in the remote directory to my local server with the timestamp of all those files shouldnt be changed. ... (5 Replies)
Discussion started by: arunkumarmc
5 Replies

5. Shell Programming and Scripting

Checking the file in remote server using SFTP

Hello, I would appreciate if any one can help me on this. The below script start running at 12:30AM. Every 5 min, i go and check the remote site. If i see filewatch.txt over there, then i need to call another shell script and load the data into database. If i don't see that file, then i have to... (2 Replies)
Discussion started by: govindts
2 Replies

6. Solaris

Checking a file on a remote windows server

Hi Everyone! This is what I need to do... I am deploying some directories over to a windows server 2000/3 box from my solaris10 box and I need to make sure the directories exist. The only form of connection I have to work with is SSH Currently, my script deploys the directories over... (13 Replies)
Discussion started by: Keepcase
13 Replies

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

8. Shell Programming and Scripting

Checking for availability of remote server

Hi. In my KSH script I'm running a command on a remote server. I want to know how I can test to see if the remote server is available (accessible) prior to running the command. Any ideas? My command looks like: `ssh $USER@$TARGET_SERVER_DNS ls -l $REMOTE_FOLDER ` This check should be... (4 Replies)
Discussion started by: dylanmilks
4 Replies

9. IP Networking

Checking for availability of remote server

Hi. In my KSH script I'm running a command on a remote server. I want to know how I can test to see if the remote server is available (accessible) prior to running the command. Any ideas? My command looks like: `ssh $USER@$TARGET_SERVER_DNS ls -l $REMOTE_FOLDER ` This check should be... (1 Reply)
Discussion started by: dylanmilks
1 Replies
Login or Register to Ask a Question