Sponsored Content
Full Discussion: Shell script to connect
Top Forums Shell Programming and Scripting Shell script to connect Post 302966690 by ceciaide on Monday 15th of February 2016 02:05:22 PM
Old 02-15-2016
Shell script to connect

hello
i try to made a report to conect all database to diferent OS
HP-UX/LINUX/SOLARIS/AIX
this is my example
i have 5 db
OS are HP-UX
Code:
ps -fea | grep pmon
    root  1120     1  0  Nov 29  ?         5:14 ipmon -sD
  oracle 10286     1  0  Nov 29  ?        27:19 ora_pmon_BD1
  oracle 10431     1  0  Nov 29  ?        20:25 ora_pmon_BD2
  oracle 11728     1  0  Nov 29  ?        24:40 ora_pmon_BD3
  oracle 11882     1  0  Nov 29  ?        46:59 ora_pmon_BD4
  oracle 12068     1  0  Nov 29  ?        25:42 ora_pmon_BD5

my script

Code:
ps -fea | grep '[_]pmon[_]' | while read -r line
do	printf '%s\n' 
# Assign the ORACLE_SID
ORACLE_SID="${line##*_pmon_}"
export ORACLE_SID
echo  "My db :" $ORACLE_SID
done

pgrep -lf ora_pmon |
  while read p a; do

#Find ORACLE_HOME info for current instance
     ORATABLINE=`printf '%s\n'  \
     "$( dbhome "${a#ora_pmon_}" )"`
    ORACLE_HOME=`echo $ORATABLINE`
    export ORACLE_HOME
echo "my Home:" $ORACLE_HOME

  # Put $ORACLE_HOME/bin into PATH and export.
    PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc ; export PATH

done

sqlplus -s <<EOF
connect / as sysdba
select instance_name,status,database_status from v\$instance;
select * from v\$version;
EOF
done

when im run the script

My db: BD1
My db : BD2
My db :BD3
My db : BD4
My db: BD5
my Home: /oracle/10.2

try to connect to sqlplus but
only coneect BD5
and execute the 5 times

can help me
to the result look like this:
Code:
My db: BD1
my Home: /oracle/10.2
My db : BD2
my Home: /oracle/10.2
My db : BD3
my Home: /oracle/10.2
My db : BD4
my Home: /oracle/10.2
My db: BD5
my Home: /oracle/10.2


Moderator's Comments:
Mod Comment Please use code tags for all your data and code next time, thanks

Last edited by vbe; 02-15-2016 at 03:37 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to connect DB2 table using shell script

Hi All, I want to connect two tables in DB2 using shell script and then compare the contents of two tables field by field. Could any one please help me in connecting database tables using Unix and retriving data from the same. Thanks, Durwas (0 Replies)
Discussion started by: dtidke
0 Replies

2. Shell Programming and Scripting

Connect two servers in shell script

Hello all, I know that is a question which has made too many times, and I have been looking into the threads but all posted was not sucessfully for me so... I need a shell script which connect two unix servers, but NOT using ssh... Is there another way to do it? I've tried ssh but it didn't... (1 Reply)
Discussion started by: Geller
1 Replies

3. Shell Programming and Scripting

vpn connect/disconnect shell script

Hi I am not so good in scripting..trying ot learn it...need guidance of the experts in shell scripting.. Let me explain the scenario first.. a server MX1 is connected to another server MX2 through vpn..every 5 minute a script runs to test vpn connectivity between the 2 servers.when the vpn... (12 Replies)
Discussion started by: renuka
12 Replies

4. Shell Programming and Scripting

Connect to oracle db using shell script

Hi, I want to connect to oracle db using unix shell script. And i want to retrieve data from db through shell script. Please help me as soon as possible. Thanks, J.P. Das (1 Reply)
Discussion started by: jyotidas
1 Replies

5. Shell Programming and Scripting

connect to db2 using shell script

Guys, I am trying to write a shell script that connect to wcsprod database and read the query #!/bin/ksh sqlplus -s < connect to wcsprod user wcsadm using pwd > select * from catentry fetch first 1 row only with ur; databse: wcsprod user: wcsadm pwd: pwd thanks (1 Reply)
Discussion started by: skatpally
1 Replies

6. Shell Programming and Scripting

Shell Script to connect to the oracle database

Hi Unix Gurus, I have a requirement to write a script, Oracle DB gets referesh every 6hrs, hence we need write a script to connect to the database , if it connects it should generate a file to proceed the next job application or when an error when connectiong to DB it should not generate any... (8 Replies)
Discussion started by: bshivali
8 Replies

7. Shell Programming and Scripting

How to connect to Oracle database using shell script?

Hi All, I am newbie to unix shell scripting. I want to connect to oracle database using shell script. I know how to connect DB using user name and password but my question is if my password is having '@' sign then how to connect. I have tried like below, cnt=`sqlplus -s /nolog << EOFSQL ... (3 Replies)
Discussion started by: pmotewar
3 Replies

8. Shell Programming and Scripting

Shell script to connect from one server to other

Dear Experts, I am new to the shell scripting. I am looking for a shell script to connect to one Unix/Linux server1 to other Unix/Linux server2 and trigger a SAP Event in that server2 (Which will trigger a job in SAP). Is this possible to connect from one server to the other server securely... (7 Replies)
Discussion started by: Venu V Reddy
7 Replies

9. Shell Programming and Scripting

How to Connect to Teradata and Run in Shell Script?

Hi Master, I need to create dan run script in linux to get data from teradata I did this ---------- Post updated at 02:28 AM ---------- Previous update was at 02:25 AM ---------- LOG_DIR="/home/"; OUTDIR="/home/"; SCRIPT_NAME=“test"; DUMPFILE="${OUTDIR}${SCRIPT_NAME}"_"$(date... (2 Replies)
Discussion started by: radius
2 Replies

10. Shell Programming and Scripting

Not able to connect to Oracle server from shell script

Hi, I am facing an issue in connecting to database from Linux shell script. Here is my code export ORACLE_BASE=xxx export ORACLE_SID=xxx export ORACLE_HOME=xxxx DB_PATH=xxx/'yyy@yy' UserId=`sqlplus -s $DB_PATH <<EOF set head off feedback off select max(USER_ID)+1 from USERS;... (6 Replies)
Discussion started by: yuvi
6 Replies
All times are GMT -4. The time now is 07:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy