Using osascript, I'm able to tell the Terminal application to open an ssh connection in a separate terminal window, however, I run into errors when trying to pass bash variables in the script.
This script works just fine:
osascript -e 'tell app "Terminal"
do script "ssh user@hostname -p port -L 9999:localhost:80 -i keyfile"
end tell'
...more commands...
But running a script like this one...
read -p "Port: " prt
read -p "Localhost port: " lhprt
osascript -e 'tell app "Terminal"
do script "ssh user@hostname -p \"$prt\" -L \"$lhprt\":localhost:80 -i keyfile"
end tell'
...more commands...
It doesn't pass the variables, i.e. the command passed in the new terminal window is
ssh user@hostname -p "$prt"
How might I format this to make it so my bash variables get fed through?