The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-08-2005
Mark Puddephat Mark Puddephat is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 6
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0