Unable to use End of transmission (EOT) with ssh command inside if, it gives compilation error. I have tried using <<-EOT and <<<EOT but nothing worked. Can anyone suggest a fix for this?
#!bin bash
if [ -z "$2" ];
then
rsync -a abc.tgz root@$1:/var/folder1
echo "Done upload"
# Change permissions of agent image and create image configuration
ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no root@$1<<EOT
chmod 644 /var;
echo "image.id=$containerSha" > /var;
EOT
else
rsync -a abc.tgz root@$1:/var
echo "Upload done"
ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no root@$1<<EOT
cd /var;
sshpass -p '$3' rsync -a abc.tgz root@$2:/var;
sshpass -p '$3' ssh root@$2 'chmod 777 /var/*; ls -ltr';
EOT
fi
exit