how to assign value to the variable through ssh

Hi All,

i am writing a shellscript to compare cksum of the file in local machine and after copying to remote machine. i am not able to assign command output value to variable in remote machine through SSH. PFB code for this.

code:

###### Get File size of the file in local  remote system

cd $artifact_location
localsystem_filesize=`cksum $filename`
echo "local file size is :$localsystem_filesize"

###### Get File size of the file in local  remote system

ssh -l $scp_username $hostname <<EOF 2>/dev/null
        Y

        cd $remote_release_path
        remotesystem_filesize=`cksum $filename`
        echo "remote file size is :$remotesystem_filesize

        if [ $localsystem_filesize == $remotesystem_filesize ]
        then
        echo "file size is equal"
        else
        echo "file size is diffrent"
        exit 1
        fi
EOF

can any one please help me here.....

Thanks,
Katam Sivakumar

try replace this

ssh -l $scp_username $hostname <<EOF 2>/dev/null
Y

cd $remote_release_path
remotesystem_filesize=`cksum $filename`

with this

remotesystem_filesize=`ssh -l $scp_username $hostname "cd $remote_release_path;cksum $filename"`

also you must rearrange your code to eliminate the EOF coding

1 Like

If you have the option to use rsync , there is a checksum option -c built in.

1 Like

thanks a lot ryandegreat25. its working fine.