Compressing output via pipes

From: Orr, Steve (sorr_at_rightnow.com)
Date: 11/26/03


Date: Wed, 26 Nov 2003 13:49:49 -0700
To: <python-list@python.org>

Oracle provides an export utility (exp) and I have a shell script which
compresses its output (not stdout) thru a pipe but l need a platform
portable Python script for this.

Here's the shell script:
------------------------------------------------------------------
#!/bin/bsh
LOG_NAME='/tmp/expzip.log'
FILENAME='/tmp/expzip.dmp'
/bin/mknod $FILENAME p
/usr/bin/gzip <$FILENAME>$FILENAME.Z &
$ORACLE_HOME/bin/exp system/manager@local FULL=Y file=$FILENAME
log=$LOG_NAME
/bin/rm $FILENAME
------------------------------------------------------------------

Here's a Python script which runs the exp utility without on the fly
compression:
------------------------------------------------------------------
import os
expcmd = '/u01/app/oracle/product/9.2/bin/exp'

def expDB(theUser,thePW,theSrvr,dmpFile,logFile):
    cmd='%s userid=%s/%s@%s full=y file=%s
log=%s'%(expcmd,theUser,thePW,
 
theSrvr,dmpFile,logFile)
    cmdout = os.popen(cmd)
    cmdout.close()

def main():
 
expDB('system','manager','local','/tmp/exptest.dmp','/tmp/exptest.log')

if __name__=='__main__':main()
------------------------------------------------------------------

I want to compress the *.dmp dump file on the fly without having to
compress an intervening file. I know I need to do something with pipes
and/or os.dup2() but I'm struggling. Has anyone done something like
this?

TIA,
D. B. Dweeb



Relevant Pages

  • Re: system hangs during dump + compress > usb2-drive
    ... system hangs during dump + compress> usb2-drive ... When system hangs, no sub system, such video, network, etc, will ... The problem we can see now is that tar (probably the pipe) process only finish ... So, I suspect this is a pipe problem, not a compress issue. ...
    (freebsd-hackers)
  • Re: system hangs during dump + compress > usb2-drive
    ... system hangs during dump + compress> usb2-drive ... When system hangs, no sub system, such video, network, etc, will ... The problem we can see now is that tar (probably the pipe) process only finish ... So, I suspect this is a pipe problem, not a compress issue. ...
    (freebsd-questions)
  • Re: DCL Pipe/ZIP performance
    ... > with the output piped into first a search command and then InfoZip to ... > compress the results, without creating a large intermediate file. ... > Later I can use pipe and unzip to decompress into further search ... > large as 5GB but even minimum compression with InfoZip reduces them by ...
    (comp.os.vms)
  • csh shell script situation
    ... execution of script doesnt complete ... I've included shell script below: ... setenv PIPE $home/trainrefresh/trainrefresh_ora.dmp ... In essence I'm trying to dump file content into pipe then have Oracle ...
    (comp.unix.shell)
  • Re: Piping into a shell script
    ... > I want to write a shell script in bash, where I can pipe other commands ...
    (comp.os.linux.misc)