Script fails with ORA-20000 when run with su

Hi,

I have a ksh script that runs as root ans issues several commands as a user differente from root as 'su <user> -c "command" ' . It works fine except for one step where the command executes sql statements. That command fails with ORA-20000.
Now the strangest thing, if I place a read command just before that su everything works fine. I've tried a sleep 10/20/30 instead of read and it didn't work.
This is supposed to be an automation script so it must not pause waiting for input from the user.
Can someone help?

Thanks and kind regards

ORA-20000 errors are generated by exceptions in stored procedures or other PL/SQL code. Check that first, maybe it's depending on some other background procedure. Also, are you reading from a file in a loop? Could be that the command for the database connection (sqlplus, or something else) is reading incorrect data from there.

Hello Pludi,
the exception comes from a PL/SQL procedure. I wonder how, without changing anything else other than putting "read" before the su command that ultimately runs that PL/SQL makes it work. I was thinking of something in the line of "the read command flushes the DBMS_OUTPUT buffer" but I have nothing to support this nor do I have a way to control this behaviour.

Tnx

Couldn't say without seeing the code. But you could try using read this way and see if it makes a difference:

read </dev/null

Didn't work!

Try to put the code here.

Are you using DBMS_OUTPUT?

If so, try the following:

set serveroutput on size 1000000

By default, you can output 2000 characters, the maximum is 1,000,000.