You MUST NOT put your password in a script, use public key authentication mixed with ssh-agent-forwarding to achieve what you want, it was created to alleviate the need for a password even if you "traverse" many ssh servers.
For the cost of a mere ssh-copy-id to all the servers you will be able to connect from/to any of them.
Here is a guide to setup Agent Forwarding: http://unixwiz.net/techtips/ssh-agent-forwarding.html
edit: The part you're looking for is the one named "Public Key Access with Agent Forwarding" (sorry, no anchors in the article) but you should read the page fully because it presents all the modes of authentication supported by SSH and the last part builds on the former ones.