Execute multiple ssh commands in the same shell (programatically)

view full story

http://serverfault.com – NOTE: I'm really looking for an SSH-y solution here, more than bash-y one. I need to execute a series of commands over ssh, programatically. There are many ways to do this, but I can't find any that works with my constraints: some of the commands set variables in the shell. Therefore I dont think I can make this work using multiple shells. some of these variables are functions, not normal values, so I dont think I can simply serialize the output of env to "restore" the old environment. I need to access the stdout, stderr and exit code of each command separately. This makes it difficult to c (HowTos)