Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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


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

share|improve this question
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 '13 at 16:25
up vote 6 down vote accepted


ssh -n "nc -l 8023 | mbuffer -s 128k -m 1G | zfs receive $zfsPath &"
zfs send $newestSnap | mbuffer -s 128k -m 1G | nc -w 60 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.