'How to execute a shell script and continue typing?

I'm trying to execute a shell script that ssh's into a jump server, enter a password and then be able to enter commands or ssh into another server. The issue is that the script ends and I can't enter anymore commands and it exits.

I'm not that proficient in shell scripting, I was hoping someone else had done something similar.

#!/bin/bash
/usr/bin/expect <<EOD
spawn ssh [email protected]
expect "Password"
send "$1\n"
expect eof
$SHELL
EOD


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source