Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

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
add comment

1 Answer

up vote 6 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

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.