![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Korn shell and awk question | mastachef | Shell Programming and Scripting | 6 | 10-31-2007 07:15 AM |
| korn shell question | mich_elle | Shell Programming and Scripting | 4 | 02-22-2006 09:03 PM |
| Korn Shell Loop question | stevefox | Shell Programming and Scripting | 4 | 12-09-2005 01:27 AM |
| AWK question in the KORN shell | penfold | Shell Programming and Scripting | 11 | 02-09-2005 09:14 AM |
| Question about Korn Shell | Latha Nair | Shell Programming and Scripting | 13 | 11-05-2003 07:30 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Korn Shell Coprocess Performance Question
I am wracking my brains over this. I am trying to use a Korn Shell script to execute an Oracle PL/SQL procedure, using the Oracle command line interface (sqlplus). The script starts sqlplus in a coprocess, and the two processes communicate using a two-way pipe. The bgnice option is off, so both processes run at the same priority. The operating system is AIX 5.1. Here's the problem. If I run the PL/SQL procedure using the script, it takes (quite literally) about ten times as long to run as it would take were I to start sqlplus myself, and run the procedure manually. There is one more piece to this. Since I cannot predict how many lines will be output from the coprocess, I use a "suicidal read" technique to stop the script waiting indefinitely on the pipe. Can anyone help? Here is a code fragment: Code:
while true ; do
(sleep 1 ; kill $$ 2>/dev/null) & # Set up alarm process to
bp=$! # kill read after 1 second
OLDIFS="$IFS" # Read data from SQL Plus
IFS='' # without splitting into
rc=0 # individual fields
result=""
read -rp result 2>/dev/null
rc=$?
IFS="$OLDIFS" # Restore field delimiters
if (( rc != 0 )) ; then # If a read error occurred
kill $bp 2>/dev/null # kill the alarm process
exitnow=1 # exit from func and script
break
fi
if kill $bp 2>/dev/null ; then # If we killed the alarm
set -- $result # Split data into fields
if [[ "$1" = "SQL>" ]] ; then # Remove leading SQL
while [[ "$1" = "SQL>" ]] ; do # prompts from output
shift
result=$(print "$result" | cut -c6-)
done
fi
else
sleep $pollInterval # Wait if alarm timed out
fi
done
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|