Hi,
I am trying to run commands on a list of servers that I can ssh to and just want to know if there is a 'cleaner' way of doing this.
At the moment, I am doing as below. Is there a way that I can escape the double quote differently? If a use a single quote to enclose the commands that I want to run, it does not evaluate the variable even though they are enclosed in curly braces.
FYI, I am using Korn shell. Thanks in advance.
test_ssh ()
{
for server in ${server_list}
do
echo
echo "/+ ---------------------------------------------------------------------------------------------- +/"
echo
echo "- ssh test on server => ${server} - FIRST cat"
testfile="/tmp/${server}_tmp"
echo ""
ssh ${server} "cat ${testfile}"
echo ""
ssh ${server} "touch ${testfile}"
ssh ${server} "ls -l ${testfile}"
marker="${marker_start} - `date`"
#echo "- marker = ${marker}"
ssh ${server} "echo \"\" >> ${testfile}"
ssh ${server} "echo \"${marker}\" >> ${testfile}"
ssh ${server} "echo \"\" >> ${testfile}"
echo ""
echo "- ssh test on server => ${server} - SECOND cat"
ssh ${server} "cat ${testfile}"
echo ""
sleep 5
echo
echo "/+ ---------------------------------------------------------------------------------------------- +/"
echo
done
}