« Shuttle | Main

March 11, 2014

executing multi-line shell script over ssh

#!/usr/bin/env bash

ssh user@host /bin/bash -c '
stuff=`foo | awk '\''{print $4}'\'' | grep -v bar | wc -l`;

while [[ "$stuff" -ne "0" ]]; do
  printf "Foo count: %d\n" $foo;
  sleep 5;
  stuff=`foo | awk '\''{print $4}'\'' | grep -v bar | wc -l`;
done
echo "no more foo";
'
done

exit 0;

Posted by ed at March 11, 2014 4:10 PM