RE: Run command on sqlplus repetitively without reconnection

  • From: "Wolfson Larry - lwolfs" <lawrence.wolfson@xxxxxxxxxx>
  • To: <philipsd@xxxxxxxxx>
  • Date: Thu, 24 May 2007 14:08:26 -0500

Philip,
            Thanks for the clarity.  I guess I really didn't understand
co-processes on pages 62-63 of "The New KORNSHELL" by Bolsky & Korn.
I did figure out it was going back to the screen I just didn't get "p"
from "<&p" until you pointed it out on the man page.
Thanks a lot.
 
    I am running 
print -p -- "@$1" 
      in the while loop
 
    as then we can change what we're running at any time.
Nice to be able to run a command or alternate script.
 
    Thanks
    Larry

________________________________

From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Philip Douglass
Sent: Wednesday, May 23, 2007 7:23 PM
To: Wolfson Larry - lwolfs
Cc: oracle-l
Subject: Re: Run command on sqlplus repetitively without reconnection


From the ksh man page:
     <&p   The input from the co-process  is  moved  to  standard input.

So, what this is doing is starting up a cat with the co-process attached
to its STDIN, so that the output the co-process produces is output to
the screen. 

The sqlplus arg is a plain forward slash because I have an OS
authenticated (OPS$) account. If you use /nolog then you will need to
have the authentication embedded in the script, something I prefer not
to do when possible, especially for DBA accounts (like mine!) 

as for:
        print -p -- '/'
I expect that when a single sql statement is run, a forward slash will
execute it again, and again, and again... If the script you are
executing has more than one statement that you want to loop over, then
it would be appropriate to change that to @$1 of course. 


On 5/23/07, Wolfson Larry - lwolfs <lawrence.wolfson@xxxxxxxxxx> wrote: 

        Philip,
         
           1)  Can you explain this syntax, that is exactly what is
happening here?
        cat <& p &
            
            2) to get this to work on Solaris I had to change this line 
        from
        
        sqlplus -s / |& # Open a pipe to SQL*Plus
        to
        sqlplus -s /nolog  |& # Open a pipe to SQL*Plus
         
         
            Thanks
            Larry Wolfson

________________________________

        From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Jared Still
        Sent: Wednesday, May 23, 2007 1:23 PM
        To: philipsd@xxxxxxxxx
        Cc: oradbt054@xxxxxxxxx; cichomitiko@xxxxxxxxx;
oracle-l@xxxxxxxxxxxxx
        Subject: Re: Run command on sqlplus repetitively without
reconnection
        
        
        
        On 5/22/07, Philip Douglass <philipsd@xxxxxxxxx> wrote: 
        

                Here's what I've been using for awhile now to accomplish
the repetitive monitoring script in SQL*Plus pattern:
                
                #!/bin/ksh
                
                sqlplus -s / |& # Open a pipe to SQL*Plus
                
                cat <& p &
                
                print -p -- "exec
dbms_application_info.set_client_info(client_info =>
'${USER}@${HOSTNAME}');"
                print -p -- "exec
dbms_application_info.set_module(module_name => '$(basename $0)',
action_name => '$1');" 
                
                print -p -- "@$1"
                
                while (true); do
                        sleep $2
                        print -p -- '/'
                done
                
                


        Thanks, this is clever.
        Just now I have a use for it. :)
        
        -- 
        Jared Still
        Certifiable Oracle DBA and Part Time Perl Evangelist
        
        
************************************************************************
***
        The information contained in this communication is confidential,
is
        intended only for the use of the recipient named above, and may
be legally
        
        privileged.
        
        If the reader of this message is not the intended recipient, you
are
        hereby notified that any dissemination, distribution or copying
of this
        communication is strictly prohibited.
        
        If you have received this communication in error, please resend
this
        
        communication to the sender and delete the original message or
any copy
        of it from your computer system.
        
        Thank You.
        
************************************************************************
****


Other related posts: