Remote to server and run tmux in detached mode with pipe

40 Views Asked by At

I am trying to remote to server with ssh and run a tmux on the remote server with a command in detached mode. The command I want to run in tmux needs a pipe character.

I have tried escaping the | character with \ but that doesnt seem to do it.

My current command:

ssh [email protected] -C tmux -s -d MySession 'nc -l 10000 | zfs receive tank/remotepool'
1

There are 1 best solutions below

1
Barmar On BEST ANSWER

Put the entire remote command in quotes so the nested quoted string will be processed properly.

ssh [email protected] -C "tmux -s -d MySession 'nc -l 10000 | zfs receive tank/remotepool'"