Re: Embeding commands for remote database

Re: Embeding commands for remote database

 

  

Or did you want something like this
echo ""
echo $ORACLE_SID
echo ""

sqlplus -s / <<SQL_EOF
col username format a20
col osuser format a15
col machine format a30 heading 'Where from'
col sessions heading 'Sessions'
col substr(status,1,1) format a1 heading 'S'
set pages60

break on report
compute sum of sessions on report

select distinct
username,osuser,machine,substr(status,1,1),count(machine) sessions
from v\$session
where username is not null
group by username,osuser,machine,substr(status,1,1);
SQL_EOF



JEFFERY wrote:

>Here is an example of how I check (on Solaris, using a C shell [.csh] )
>that passwords being prompted for in a different part of the script is
>valid.
>You can place your sql where the "select...." statement is.
>Jeff
>==================================================================
>
>if ( $sitetype == "PT" || $sitetype == "TT" ) then
> foreach LOOPSITE ( $site1 $site2 $site3 )
> $ORACLE_HOME/bin/sqlplus -s <user>/$<user_pw>@$LOOPSITE >
>../TEMP/password_test1.temp.$LOOPSITE <<EOF
> set heading off echo off verify off feedback off linesize 120
>pagesize 0 termout off;
> spool ./TEMP/connection_test1.sql.$LOOPSITE
> select 'valid_connection' from dual;
> spool off;
> exit
>EOF
> set TEMP=`cat ./TEMP/password_test1.temp.$LOOPSITE | grep
>valid_connection | cut -d ':' -f1 | wc -l`
> if ( $TEMP != 1 ) then
> echo " "
> echo
>"-----------------------------------------------------------"
> echo "--> ERROR: Shell_Script terminated. "
> echo "--> Password for TIER1 not valid at SITE '$LOOPSITE'."
> echo "--> "
> echo "--> exiting $0 "
> echo
>"-----------------------------------------------------------"
> echo " "
> exit
> else
> echo " "
> echo
>"-----------------------------------------------------------"
> echo "--> Password for <user> is valid at SITE '$LOOPSITE'."
> echo
>"-----------------------------------------------------------"
> echo " "
> endif
> sleep 1
> end #end the looping for sites
>
>endif
>
>-----Original Message-----
>From: oracledba-return-133158-JEFFERY.L.SCHRENK=saic.[Email address protected]
>[mailto:oracledba-return-133158-JEFFERY.L.SCHRENK=saic.[Email address protected]
>On Behalf Of quigleyd
>Sent: Thursday, October 05, 2006 11:46 AM
>To: LazyDBA Discussion
>Subject: Embeding commands for remote database
>
>
>I am currently running script that excute commands on other servers, is
>there an
>easy way to put the command directly in the script, instead of putting
>it in
>another file. I want to be able to pass a balue to the sql that it is
>excuting
>instead of the "START" i would just like to put the commands there.
>
>This is what i currently do
>sqlplus -s 2>&1 << ENDSQL
>id/[Email Address Removed] sqlfile
>ENDSQL
>
>
>----------------------------------------------------------------
>This message was sent using IMP, the Internet Messaging Program.
>
>
>---------------------------------------------------------------------
>TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
>To post a dba job: http://jobs.lazydba.com
>To Subscribe : http://www.LazyDBA.com
>To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
>
>---------------------------------------------------------------------
>TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
>To post a dba job: http://jobs.lazydba.com
>To Subscribe : http://www.LazyDBA.com
>To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
>
>
>
>

Oracle LazyDBA home page