473,397 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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>$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

Jul 18 '05 #1
2 1972
"Orr, Steve" <so**@rightnow.com> writes:
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.


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
Jul 18 '05 #2
On Wed, 26 Nov 2003 13:49:49 -0700, Orr, Steve wrote:
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?


Are you sure you need pipes?

http://www.python.org/doc/current/lib/module-zlib.html
http://www.python.org/doc/current/lib/module-gzip.html

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.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christian Hammers | last post by:
Hello I would like to call a unix shellscript from within a PHP script and - write data to its STDIN - read data from its STDOUT *and* STDERR - get its exit code afterwards proc_open seems...
2
by: Patrick L. Nolan | last post by:
I'm going nuts trying to port an application from Linux to Windows. We have a python/Tkinter script which runs a C++ application. It starts it with popen4 and communicates through the two pipes....
0
by: Yuancai \(Charlie\) Ye | last post by:
Hi, All: I am happy to annouce that we have formally released our latest SocketPro version 4 at www.udaparts.com, an advanced remoting framework written from batching/queue, asynchrony and...
5
by: glenn.owens | last post by:
In the process of doing some routine monitoring/clean-up we've discovered that several (many?) users are apparently set to access our SQL Server 2000 database instances via the Named Pipes...
4
by: RobKinney1 | last post by:
Hello, For security reasons, we need to start overhauling our old C++ applications to run as services instead of applications running on the admin account. I am re-writing these programs using...
3
by: ZhukovL | last post by:
I'm having some trouble implementing the handling of multiple pipes in a shell I'm writing. I was hoping someone could point me in the right direction because I really cant see where I'm going...
2
by: bearophileHUGS | last post by:
Helmut Jarausch: Asking in comp.compression is a good starting point. My suggestions (sorry if they look a bit unsorted): it depends on what language you want to use, how much you want to...
16
by: Okonita via DBMonster.com | last post by:
Hi all, I am comming along with all this Linus/DB2/scripting business...I am no longer scared of it!! (LOL). But, I need to create a .ksh script that does a REORGCHK and output only tables...
6
by: drhilbert | last post by:
Dear all, in these days, we have found a problem we can't solve even after long long googling, so we are here asking your precious help. In our program instead of using cout to print messages...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.