I'm trying to write a script which spawns multiple long-running commands on both a remote and local machine. Currently, an example of my solution would be:
#!/bin/bash
ssh -t [email protected] tmux new -s remote -d "find / *"
tmux new -s local -d "find / *"
However, when these commands become more complex (long, chained commands with quotation marks in them, instead of just a single find
command), it becomes messy to put them on a single line and escape all the nested quotation marks.
I have tried using SSH with a so called "here document", e.g.:
ssh -t [email protected] << EOF
tmux new -s remote -d "find / *"
EOF
tmux new -s local -d "find / *"
But this leads to either the error not a terminal
with the -T or -t option for SSH, or to some very strange behavior when using the -tt option.
Any suggestions to optimize/dramatically alter my approach?