6

I have a script where I would like to start nc in listening mode on 10.10.10.11, but I would like to do it from 10.10.10.10, where I have this script

ssh -n 10.10.10.11 nc -l 8023 | mbuffer -s 128k -m 1G | zfs receive $zfsPath
zfs send $newestSnap | mbuffer -s 128k -m 1G | nc -w 60 10.10.10.11 8023

The problem is, that if I execute the script from 10.10.10.10 then it won't continue after the first line have been executed, because nc is now waiting/listening for a connection on port 8023.

Question

I would like to execute the above from 10.10.10.10, but how do I get it to continue after the first line?

1
  • You can start things in the background by using & behind the command. I am not sure of the precise syntax, but if you put all in one [shell]command and add & it should work.
    – Hennes
    Feb 13, 2013 at 16:25

1 Answer 1

6

Try

ssh -n 10.10.10.11 "nc -l 8023 | mbuffer -s 128k -m 1G | zfs receive $zfsPath &"
zfs send $newestSnap | mbuffer -s 128k -m 1G | nc -w 60 10.10.10.11 8023

This runs the command and puts it in the background allowing control to pass on to the next line.

I don't have a zfs system to hand so tested it with

ssh -n remote.tld  "nc -l 8023 | wc -l  >/tmp/test &"
ls | nc -w 60 remote.tld 8023

and the correct output appeared in the remote /tmp/test file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .