I need hostname from below entry.How do I write a script on this?tnsping is utility in oracle -if I do tnsping ora11gb then it would give one output and I want to extract hostname from this output which come after "HOST="
oracle@brookford:~> tnsping ora11gb|grep -i HOST
Attempting to contact (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bovina.int.westgroup.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ora11gb)))
We have a task of password change activity for databases and servers every quarter.
Now, in case I need to change db sys user password at primary I have to transfer password file to the standby database server.For this I should know after logging to primary that what is the standby site of this primary where I need to scp the file.
Now I am on primary site and my target is to copy password file to standby via script .First I will look at below query:
SQL> select DESTINATION from v$archive_dest where target='REMOTE';
DESTINATION
------------------------------
ora11gb
Now,I know tnsentry of standby .I will grep hostname from tnsentry and will scp password file to standby.So, this all I am planning to do in a script.
1. login to server ( will login to server from a group of servers via script)
2.set the environment of database one by one in case of multiple databases
3.login to database
4.change sys password
5.Look if the primary has a standby and grep hostname from tnsentry of standby
6. scp password file to standby
Best regards,
Vishal
---------- Post updated at 06:30 AM ---------- Previous update was at 06:00 AM ----------
Hi,
For a start I have written below code but giving error and one more query what's difference if I write
x= echo $i|cut -f1 -d':'
or
x=echo $i|cut -f1 -d':'
(removed space after "=" between x and echo)
oracle@brookford:~> cat test_passwordcopy.sh
for i in `cat /etc/oratab|grep -v '^#'`
do
x= echo $i|cut -f1 -d':'
export ORACLE_SID=$x
echo $x
y= echo $i|cut -f2 -d':'
export ORACLE_HOME=$y
echo $y;
sqlplus / as sysdba<<EOF
select DESTINATION into $z from v\$archive_dest where target='REMOTE';
EOF
echo $z;
done
oracle@brookford:~> ./test_passwordcopy.sh
./test_passwordcopy.sh: line 13: warning: here-document at line 9 delimited by end-of-file (wanted `EOF')
./test_passwordcopy.sh: line 14: syntax error: unexpected end of file
oracle@brookford:~>