What is your script trying to do? If the SSH connection is trying to run any commands after logging it, it will fail.
So, the following will not work:
ssh firstname.lastname@example.org 'show services'
but I am seeing that the following does:
echo show services | ssh email@example.com
not that it is particularilly pretty, but it will work. Something else that may be worth a try is writting the script in TCL, but it has been far too long since I touched that to be of much use helping.
AWESOME! That work perfectly.