[SunHELP] offtopic ( oracle and "pipe")

TAG DBA dbatag at tatainfotech.com
Tue Feb 12 02:50:49 CST 2002


Wow !! I was bowled over by your explanation and thanks for typing the script too....
It took me a little time to understand the explanation - but when I ran the script - things became clear.
I am impressed !!!
Thanks a lot !!!
~aslam

-----Original Message-----
From:	DAUBIGNE Sebastien  - BOR (   SDaubigne at bordeaux-bersol.sema.slb.com ) [SMTP:SDaubigne at bordeaux-bersol.sema.slb.com]
Sent:	Monday, February 11, 2002 8:45 PM
To:	sunhelp at sunhelp.org
Subject:	RE: [SunHELP] offtopic ( oracle and "pipe")

Firstable, "exp" typically tries to read stdin for passwd.
You should redirect stdin to /dev/null to tell "exp" not to wait for user
answer.
To do this, just insert '0</dev/null' when you call "exp".

exp $USERPASS full=y consistent=y buffer=1000000 file=${PIPEFILE}
0</dev/null

Note that if you launch it via cron, the "0</dev/null" stuff is not useful
as cron already redirects stdin to /dev/null .

Next,  your script will block because "exp" will not open $PIPEFILE (as
login/passwd is wrong).
So "compress" will open $PIPEFILE and wait for some peer to open the other
side of the pipe. The peer should be "exp", which finally will not open the
pipe, so "compress" will remain blocked on the open() call, until the system
shuts down or you kill it.

Note that you don't have to launch both commands via  "|", you simply have
to launch "compress" in the background.
I recommend you to trap errors from "exp" and to kill "compress" if they
occured :

#! /bin/ksh

# Launch "compress" in the background, store its pid
compress < ${PIPEFILE} > $DMPFILE &
pid_compress=$!

# Launch "exp" in the foreground, and trap errors
exp $USERPASS full=y consistent=y buffer=1000000 file=${PIPEFILE}
0</dev/null  2>&1 | egrep 'ORA-|IMP-' | wc -l | read nb_error

# If error occured, kill "compress" process. If not, wait for compress
process completion.
if [ $nb_error -eq 0 ] ; then
  wait
else
  kill -9 $pid_compress
fi


---
Sebastien DAUBIGNE
sebastien.daubigne at sema.fr <mailto:sebastien.daubigne at sema.fr>  - (+33)
(0)5.57.26.56.36
Sema Global Services - AFM/DW/Pessac

	-----Message d'origine-----
	De:	TAG DBA [SMTP:dbatag at tatainfotech.com]
	Date:	lundi 11 fivrier 2002 11:11
	@:	'sunhelp at sunhelp.org'
	Objet:	[SunHELP] offtopic ( oracle and "pipe")

	This is actually a Oracle related query - but maybe Unix gurus can
help me with the "pipe" part of my query:

	I have a script to compress export files when they are being
generated using a "pipe" . The key line in the script is:

	PIPEFILE=PIPE.dmp
	exp $USERPASS full=y consistent=y buffer=1000000 file=${PIPEFILE} |
compress < ${PIPEFILE} > $DMPFILE

	I notice that when I give a invalid userid/password... I am prompted
for it 3 times. And even after
	that the script does not stop - it simply hangs... I need to do a
Ctrl+C to stop the script.
	This is how it looks : ( I have simply hit ENTER to get the script
to go ahead)

	-------------------------------------------------------------------
	$ test1.sh PLUTO /backups/sfabkp/PLUTO/expdumps system/rakesh1

	Export: Release 8.1.5.0.0 - Production on Mon Feb 11 15:38:11 2002
	(c) Copyright 1999 Oracle Corporation.  All rights reserved.

	EXP-00056: ORACLE error 1017 encountered
	ORA-01017: invalid username/password; logon denied
	EXP-00222:
	System error message 2
	Username:

	EXP-00056: ORACLE error 1017 encountered
	ORA-01017: invalid username/password; logon denied
	Username:

	EXP-00056: ORACLE error 1017 encountered
	ORA-01017: invalid username/password; logon denied
	EXP-00222:
	System error message 10
	EXP-00005: all allowable logon attempts failed
	EXP-00000: Export terminated unsuccessfully


	** Note - even after 3 failed attempts the "export & pipe" does not
stop **
	** I have to hit Ctrl C **

	^Ctest1.sh[83]: /backups/sfabkp/PLUTO/expdumps/PIPE.dmp: cannot open
	-------------------------------------------------------------------

	Now my problem is that I am going to schedule this script as a cron
job.
	If the wrong password is supplied - then during cron execution - the
	script will simply hang... And I will get no clue to the problem.
	How can I get the line :
	exp $USERPASS full=y consistent=y buffer=1000000 file=${PIPEFILE} |
compress < ${PIPEFILE} > $DMPFILE
	to error out immediately ?

	Any ideas will be appreciated...
	Thanks and Regards,
	~aslam
	_______________________________________________
	SunHELP maillist  -  SunHELP at sunhelp.org
	http://www.sunhelp.org/mailman/listinfo/sunhelp
_______________________________________________
SunHELP maillist  -  SunHELP at sunhelp.org
http://www.sunhelp.org/mailman/listinfo/sunhelp

[demime 0.99c.1 removed an attachment of type application/ms-tnef]



More information about the SunHELP mailing list