Compressing output via pipes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Orr, Steve

    Compressing output via pipes

    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>$FIL ENAME.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,t hePW,theSrvr,dm pFile,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','loca l','/tmp/exptest.dmp','/tmp/exptest.log')

    if __name__=='__ma in__':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

  • Paul Moore

    #2
    Re: Compressing output via pipes

    "Orr, Steve" <sorr@rightnow. com> writes:
    [color=blue]
    > 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.[/color]

    How platform portable? If you want to do this on Windows, you're
    basically out of luck, as Windows doesn't support named pipes like
    this.

    If you're talking just Unix variants, I'd guess that a minimal shell
    script is as portable as you need.

    Paul
    --
    This signature intentionally left blank

    Comment

    • Jeremy Bowers

      #3
      Re: Compressing output via pipes

      On Wed, 26 Nov 2003 13:49:49 -0700, Orr, Steve wrote:
      [color=blue]
      > 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?[/color]

      Are you sure you need pipes?




      You probably should use os.popen2 to read the output directly and stuff it
      into a GzipFile instead of letting the operating system write the file,
      but I'm not 100% certain I understand what you're looking for.

      Comment

      Working...