I'm trying to run a set of commands on a remote machine, that includes an if statement. I'm using this to shutdown a list of kvm instances. The first line should be fine, but could be prettier, rest needs some help. ssh root@kvmsrv 'virsh shutdown $host 2> /dev/null; virsh destroy $host 2> /dev/null; sleep 2; virsh undefine $host 2> /dev/null'# Also needs to be run on remote machine# to disconnect iscsiiscsiadm -m session | grep $hostif [ $? == 0 ]; then  iscsiadm -m node -T $stserver.$host -ufi# then on local machinetid=`ssh root@storage1 'cat /proc/net/iet/volume' | grep $host | head -1 | awk '{print $1}' | awk -F: '{print $2}'`if [ $tid ]; then  echo Deleting tid:$tid from $stserver.  ssh root@$stserver ietadm --op delete --tid=$tidfiI guess I could do the same for the second portion, just separate it all with ; but if anyone goes to read my code later on they'd probably be scratching their heads...Is there a way to format all this so its readable and still makes sense and have all the remote commands execute properly?
Run if statement on remote machine
bash;ssh;shell script;kvm