[SOLVED] put dd | ssh command in backgound

Greetings,

I have an issue that has baffled me. I have done many searches, read the man documentation, and I have yet to find a solution. I am trying to run the following command within a script to copy a file across servers:

 
$(dd if="$FDIR" bs=1024 2> /dev/null | ssh "$(whoami)@$SERVER" dd of="$TDIR" bs=1024 2> /dev/null &)

It works, however, this is inside a while loop, and it blocks the loop from executing until the copy is done. The behavior that I want is for no messages from the dd command to show up in the script for the user to see, and I want to be able to run more than one copy (of different files) at a time.

I added the & at the end of the command to try to put it in the background, but it is still blocking the while loop from continuing. I am using ksh on HP-UX.

I was wondering whether anyone has any suggestions?

You want a command in backticks or $( ) to return immediately? You can't have it both ways. If you want to catch a command's output, you have to wait for it.

I don't want the output, I'm sending the STDERR output of 'dd' to /dev/null so that it doesn't show it to the user. I want to put the file copy into the background so that another can begin.

The functionality I'm looking for is similar to the batch mode / quiet function of scp, though for reasons that don't matter, I can't use scp.

So why are you using a command substitution? I mean:
$(command)
--
Bye

That's what $( ) does though -- turns its output into a string to put into a variable or command or what have you. If you don't need that, don't do that.

( dd if="$FDIR" bs=1024 2> /dev/null | ssh "$(whoami)@$SERVER" dd of="$TDIR" bs=1024 2> /dev/null ) < /dev/null > /dev/null 2>/dev/null &


# other stufff
# ...
# ...


wait # Wait for your background process to finish

Thanks guys. I used the command substitution because it seemd to solve a syntax error in another piece of code that I didn't post here. I have now fixed this error and it works exactly as I want it to.

Thanks again, your assistance pointed me in the right /dir/.