I am trying to do these in a script. I have to run some commands on a remote host. Currently, I am doing this:
ssh root@host 'bash -s' < command1 ssh root@host 'bash -s' < command2 ssh root@host 'bash -s' < command3
However, this means that I have to connect to the server repeatedly, which is increasing a lot of time between processing of the commands. I am looking for something like this:
varSession=$(ssh root@host 'bash -s') varSeesion < command1 varSeesion < command2 varSeesion < command3
Again, I need to run these commands via a script. I have taken a look at
screen but I am not sure if it can be used in a script.