Script query


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script query
# 1  
Old 10-18-2011
Script query

Hi Admins,

Code:
count=`ps -ef | grep LIST_8i | grep -v grep|wc -l`
pid=`ps -ef|grep LIST_8i|grep -v grep|awk '{print $2}'`
if [ $count = 1 ]
then
lsnrctl stop LIST_8i >> ${log}
sleep 5
lsnrctl start LIST_8i >> ${log}
else
echo " "
lsnrctl start LIST_8i >> ${log}
fi 2>&1

The script restarts listener if count is equal to 1.
This script fails when 'lsnrctl stop LIST_8i ' code aborts due to some tns adapter error.
In this scenario i had to use kill -9 <pid>.

Now i want modify script like when 'lsnrctl stop LIST_8i ' fails and kill -9 <pid> works.
Please guide me how i can achieve this.
Regards
newaix

Moderator's Comments:
Mod Comment Start using code tags - you got several PMs that explain, how to use them and additionally a link with a video tutorial. If you collect enough infraction points, you will be banned from the forum. Consider if this is worth it, thanks.

Last edited by zaxxon; 10-18-2011 at 10:52 AM.. Reason: code tags
# 2  
Old 10-18-2011
When lsnctrl stop fails, what is the value of $?, I would suggest checking the value of $? before your sleep and if it is non-zero, log the error number and go the extreme prejudice route.
# 3  
Old 10-18-2011
Thanks for the respones..

Can you please tell me how i can include the same in script..

Regards
newaix
# 4  
Old 10-18-2011
something like the following should work, provided that the lsnctrl returns a valid error state.
Code:
lsnrctl stop LIST_8i >> ${log}
if [ $? -ne 0 ] ; then
     kill -9 $pid
fi
sleep 5

However finding the base reason why lsnctrl fails to kill the process might be a more worthwhile exercise.
# 5  
Old 10-18-2011
@newaix:
Moderator's Comments:
Mod Comment
Read the moderator comment in your 1st post in this thread and read your PMs. It can't be that hard to use code tags.


Moving thread to scripting area - nothing AIX specific in it.
# 6  
Old 10-22-2011
Hi Skry,

Thanks for the same.Actually there are lots of dependencies and oracle stopped support for 8i.

Regards
newaix
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Argument to the script query

Hi, I have a script invest.sh which takes two inputs i.e the name of the properties file and the file permissions for eg: ./invest.sh app12.properties 664Now i wish to give a folder path /opt/app/properties instead of the properties file and the invest.sh script should lookout for all the... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

3. Shell Programming and Scripting

shell script query

Hi Admins, I was trying to list the failed logins as part of my daily checklist. Here is my script for i in `who -s /etc/security/failedlogins|tail -100|grep "$dt"|awk '{print $1" "$6}'` do a=`echo $i|wc -l` if then echo $i else echo "There are no failed logins" fi done but... (3 Replies)
Discussion started by: newaix
3 Replies

4. Shell Programming and Scripting

Db2 query with 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.and i should return on the screen the un matched records .. Could any one please help me in connecting database tables using Unix and retriving data from the same. (1 Reply)
Discussion started by: kanakaraju
1 Replies

5. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

6. Shell Programming and Scripting

shell script query

hi all i have a shell script for connecting in sybase env what i need is i have around 10 servers , i need to connect to all servers and retrive the database inforamtion in the servers and display them any one of u have it request to share it asap ! "QUERY TO Connect to all servers... (1 Reply)
Discussion started by: mvsramarao
1 Replies

7. UNIX for Dummies Questions & Answers

Expect Script - if/else query

Hi, I am trying to write an expect script that contains an if/else statement based on a result ... but I'm having a bit of trouble. The code below shows my script - it all works fine but when I include the second expect function it ignores it and moves on ... can anyone help with this ...... (1 Reply)
Discussion started by: spikey
1 Replies

8. UNIX for Dummies Questions & Answers

Shell script query

Hi, I am stuck assigning a value to a variable. I am trying to assign a value to a variable but getting error.... IP_ADDR=grep 'I.P. Address' /install/cfgdist/`uname -n`.cfg | cut -d : -f 2| cut -d . -f 1-3| sed s/" "//g I am using this script to grep first three octets of an IP address... (4 Replies)
Discussion started by: max29583
4 Replies

9. Shell Programming and Scripting

Query regarding portable script

Dear Experts, I want to write a script which has to work on Solaris & Linux sytems. The problem which i am facing is, there are commands whose options are different on both OS's. For example ping. On Solaris i have to write: ping $host 1 to check if the host is alive On Linux i... (4 Replies)
Discussion started by: dhiraj4mann
4 Replies

10. Shell Programming and Scripting

C Shell Script query

Hi I need a small help Cshell% more abc.txt ******** Cshell% cat abc.txt | cut -c1-3 *** Cshell%set test3=`cat abc.txt | cut -c1-3` Cshell%echo $test3 a.txt b.txt................. ..... It displays all the file in the current directory. I want *** to be displayed. Can any one of... (1 Reply)
Discussion started by: bpupdown
1 Replies
Login or Register to Ask a Question