R – ssh with command….Plus the shell

opensshrxvtshellssh

I'd like a command that ssh'es into a machine, runs a command (cd or execute a script or su), and then gives me the shell. Passing a command to ssh seems to always exit.

Some examples of what I'm looking for:
'ssh me@machine1 "./executeMyScript && cd /developmentDirectory"' and then it gives me my shell back.

The reasons I want to do this is because I'm using mrxvt (tabbed x terms) which allows me to define commands for all of my tabs to execute on startup. I'd like to have a few ssh connections to the same machine but have them do different things after sshing.

-Rob

Thanks!

Best Answer

Variation on the other answers really, use the -t option of ssh to force pseudo-tty allocation:

ssh -t me@machine ./executeMyScript '&&' bash -i