scp script with MD5


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scp script with MD5
# 1  
Old 12-11-2013
scp script with MD5

I have more than one file in my directory & I want to SCP them all with MD5 verification of local & remote file, Problem is that the script gets stop after scp one file. Below is the code.
Code:
#!/usr/bin/bash
cd /application/datafolder/my/
ls > my_file_list.txt
while read fname
do
   VAR_LOCALMD5=`csum -h MD5 /application/datafolder/my/${fname}|awk '{print $1}'`
    scp ${fname} 10.xxx.xxx.xxx:/application/datafolder/my/
    VAR_REMOTEMD5=`ssh 10.xxx.xxx.xxx csum -h MD5 /application/datafolder/my/${fname}|awk '{print $1}'`
     if [[ $VAR_LOCALMD5 == $VAR_REMOTEMD5 ]]
    then
    rm /application/datafolder/my/$fname
    echo "LOCAL MD5:  $VAR_LOCALMD5"
    echo "REMOTE MD5:  $VAR_REMOTEMD5"
    else
    echo "Error Occured in SCP files"
    echo
    echo "LOCAL MD5:  $VAR_LOCALMD5"
    echo "REMOTE MD5:  $VAR_REMOTEMD5"
    fi
    ssh 10.xxx.xxx.xxx rm /application/datafolder/my/my_file_list.txt
done < my_file_list.txt

Any help would be highly appreciated.

Last edited by vbe; 12-11-2013 at 08:38 AM.. Reason: typo
# 2  
Old 12-11-2013
Start by using ls -1 > my_file_list.txt ...
# 3  
Old 12-12-2013
its not working...please suggest
# 4  
Old 12-12-2013
Code:
ls -ltr | awk '{ print $9}' >> filelist

# 5  
Old 12-12-2013
@ m_raheelahmed which OS uname -a

@zozoo >> appends standard output to file and just ls -1 is enough
This User Gave Thanks to Akshay Hegde For This Post:
# 6  
Old 12-12-2013
AIX 6.1
# 7  
Old 12-12-2013
post this

which ls and echo $PATH I suspect path must be broken
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to reverse the b64 format(encoded b64(b64(md5($pass)))) into md5 hash format?

I have about 1500 rows (encoded b64(b64(md5($pass))) algorythm) in a file. I would like reverse the b64 into md5 hash format. How could I do that from command line? So I need only the correct md5 hash formats. These row format: 4G5qc2WQzGES6QkWAUgl5w P9tKxonBOg3ymr8vOBLnDA... (1 Reply)
Discussion started by: freeroute
1 Replies

2. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

3. Shell Programming and Scripting

scp using script

Hi all, I want to setup scp script for copying files to remote server. I did google and all refereed expect, but the script failed to work. Please lead me to some useful link or piece of script. Thanks in advance, (8 Replies)
Discussion started by: nrjrasaxena
8 Replies

4. Shell Programming and Scripting

Help with MD5 script

Hi, I tried to write script, which would be able to generate MD5 sums into txt file.. But It won't work.. (I've been trying to fix that over 4 hours, but nothing helps) Here it is #!/bin/bash FILE="nothing1" POST="nothing2" I=1 while do FILE=`ls -ltR | grep "^-" | tr -s "... (1 Reply)
Discussion started by: TheBarnacle
1 Replies

5. Shell Programming and Scripting

Create md5 sums and archive the resulting md5 files

Hello everyone, I am looking to basically creating md5sum files for all iso files in a directory and archive the resulting md5 files into a single archive in that very same directory. I worked out a clumsy solution such as: #find files for which md5sum are to be created and store the... (1 Reply)
Discussion started by: SurfTranquille
1 Replies

6. UNIX Desktop Questions & Answers

Script to compare md5

From couple of hours i try to do a script to compare file MD5. Help would be very appreciated :) First i read the md5 stored into a text file (no problem): md5=`grep -P "^{32}" $file` then i want to calculate the checksum and store it : cmd5=`md5sum licence.gvcl` then problems arrives, i... (5 Replies)
Discussion started by: giova
5 Replies

7. Shell Programming and Scripting

Need to create a simple script using MD5, SSH...

Hi all, I am brand new to these forums and I am a brand new UNIX Administartor. Don't know any scripting yet :wall:, and would like to learn as my boss is slowly letting me understand everything about being a Sys/*Nix Admin. He created this script which I am trying to replicate because I lost it... (54 Replies)
Discussion started by: zixzix01
54 Replies

8. Shell Programming and Scripting

[Bash] MD5 Checks with Script.

Hi. I'm triyng to make a Bash Script that checks (recursively) the MD5 from all the files in a certain directory and compare them against some other check that should be already done and saved in a file. I've reached to the point where i have the MD5 from the file and the MD5 that the script... (1 Reply)
Discussion started by: BiFo
1 Replies

9. Shell Programming and Scripting

scp using script

Hi, I have to copy a file from one server to another server daily using a script.How can i perform this operation. Can somebody help with the code. Regards, Ahamed. (1 Reply)
Discussion started by: ahamed
1 Replies

10. Linux

Need SCP script equivalent to FTP script .

Hi, Currently i'm using the folllowing FTP acript and its working. echo "open $server" > ftp_file echo "user $user $password" >> ftp_file echo "cd $remote_dir" >> ftp_file echo "lcd $local_dir" >> ftp_file echo "put $file">> ftp_file echo "bye" >> ftp_file ftp -nv < ftp_file I've... (1 Reply)
Discussion started by: vickramshetty
1 Replies
Login or Register to Ask a Question