Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need assistance on scripting

Status
Not open for further replies.

vishaldba

Programmer
Nov 26, 2013
1
IN
Hello,

In a loop I am using below command for every database

crsctl status res | grep -E "ora\.$DATABASE\.(.+)\.svc" and below is one of the sample output
NAME=ora.sgraphut.sgraphutxdb.svc

Now I want to extract just service name out of this string (that is sgraphutxdb) please help me how do I proceed?
Additionally,if I need to pass the node name as one of the parameters while calling this script
Let's suppose the script name is test_relocate.sh and I need to execute this like below:
test_relocate.sh -n node1
Now how do I use this argument inside the script in a loop



Best regards,
Vishal
 
Etracting the service name: pipe the string into

cut -d. -f3
 
If the service name will always be in the form as shown in your example, you can do this:

echo $NAME | awk -F. '{print $3}'

If you need that result in a variable:

SVCNAME=`echo $NAME | awk -F. '{print $3}'`
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top