scp in a multi-piped command?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

I am trying to determine a means of:

exporting from Oracle                    |
passing it through gzip or compress      |
transferring the file                    |
gzip -d or uncompress on the other end   |
import into Oracle

It is very straightforward to take an Oracle export and pipe it to
'compress'.  This works, and is a well-known technique.  What I want
to do is use scp in batch mode for the transfer.

I have read on how to set up ssh in batch mode and am pretty confident
I can get it working  between two servers.  What I am wondering is
whether anyone here has tried this (or a Sybase bcp) and/or whether
there is a gotcha I am missing.  Comments sought!

Kind regards,


Re: scp in a multi-piped command?

Quoted text here. Click to load it

scp transfers files, not pipes.  You'll want ssh.

# run the ssh on the sending end.
ls -l | compress | ssh host "uncompress > /file/location"

# run the ssh on the receiving end
ssh host "ls -l | compress" | uncompress > /file/location

Or let ssh do the compression...

ls -l | ssh -C host "cat - > /file/location"

Just change the commands above with the ones you want.

Darren Dunham                                 
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

Re: scp in a multi-piped command?

Cool!  Can't wait to try it Monday morning.

Thank you.

Kind regards,

Jared Hecker

Quoted text here. Click to load it

Kinda works, but not really :-(

Well, it kinda works, but I am running into a constraint somewhere.
Here is what I did:

On target machine:

mknod /imp/inpipe p
imp xxx/xxx file=/tmp/inpipe &

On source machine:

exp xxx/xxx file=stdout|ssh -C username@target 'cat > /tmp/inpipe'

This works great for small exports, but nothing appears to happen on
the large one I want to try.  Could it be the 2GB file size limitation
is being hit on the named pipe on the target side?  It of course
always shows a size of 0 bytes.

Quoted text here. Click to load it

Re: scp in a multi-piped command?


OK, I got it.  Here's what to do:


SOURCE = machine we are exporting from
TARGET = machine we are importing to


SSH set up to connect without passwords (RSA or DSA key pair method)
If on Solaris, change out 'cat' for GNU version (on Solaris utilities disk)
Normal Oracle exp and imp issues apply (e.g., catalog issues between db

On TARGET machine

mknod /tmp/inpipe.dmp p
imp xxx/xxx file=inpipe.dmp &   (bg is optional; I do it to make sure it blocks)

On SOURCE machine

mknod /tmp/outpipe p
ssh -C user@targethost 'cat > /tmp/inpipe.dmp' < /tmp/outpipe &
exp xxx/xxx file=/tmp/outpipe

If you have two xterms up you will be able to see the activity.

Thanks again for the help - you got me on the right track.

Kind regards,
jh (Jared) wrote in message

Quoted text here. Click to load it

Site Timeline