I'm a CS student, and still learning a lot of these things, and so please bear with me if I don't have a full grasp on what I'm trying here.
I'm on a Mac, connecting to a linux machine. I can set up an ssh tunnel and connect to the remote machine by executing the following line of script:
ssh -f -L 2222:<remote_machine>:22 <user>@<remote_server> sleep 10; ssh -p 2222 <user>@localhost
What I want to do is somehow execute this line automatically. Now, I have to copy and paste it into the terminal. I have key pairs set up, so don't have to enter passwords, but I get the prompt for my terminal type. These are the two steps I'd like to eliminate, so I can open terminal and run a script that eliminates these two steps.
What I can't figure out is how to either respond to the "terminal type" prompt or automatically respond to it. I've played around with the Expect class, and Python's pexpect module, but not had success (it seems like an expect script would be able to take care of the terminal portion, but having trouble creating the tunnel and not losing reference to the background process).
I have an applescript that does what I want, but would like a more portable solution. Any suggestions about where to look would be great!