Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Run command on sqlplus repetitively without reconnection
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_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] 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_at_acxiom.com> wrote:
Philip,
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_at_freelists.orgreconnection
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Jared Still
Sent: Wednesday, May 23, 2007 1:23 PM To: philipsd_at_gmail.com Cc: oradbt054_at_gmail.com; cichomitiko_at_gmail.com; oracle-l_at_freelists.org Subject: Re: Run command on sqlplus repetitively without
On 5/22/07, Philip Douglass <philipsd_at_gmail.com> 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 maybe 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.
-- http://www.freelists.org/webpage/oracle-lReceived on Thu May 24 2007 - 14:08:26 CDT
![]() |
![]() |