grep

cd $CCP_REL/W*/cfg
more default.cfg |grep -n "WEB_SERVER_PORT 8087" > /export/home/$USR/****/portfile

like this i need to get couple of more lines from default.cfg and store it in port file. How can i do that?

***One more question, as my next step in the script i used to do

netstat -a |grep 8087 |grep LISTEN | awk '{print $1}' > tport1
sleep 1
n=`wc -c /export/home/$USR/****/final/tport1 | awk '{print $1}'`
if [ $n -eq 0 ]
then
f=0
fi

If this condition fails then i will send echo message.

But now i need to check w/ line from the file. Not sure how i can do that.

Thanks,
Gundu

Question 1:

Use grep as,

grep -nE "WEB_SERVER_PORT 8087|LDAP_SERVER_PORT 3300" default.cfg > /export/home/$USR/****/portfile

Question 2:
Please narrate your requirement. What you are trying to get from netstat??

Example:
# netstat -a |grep ssh|grep LISTEN| awk '{print $1}'
tcp
unix

What do you want from this?

HTH.

Thanks for Q 1

Q2: From netstat i am checking whether that particular port is open or not by grep LISTEN. IF it is not LISTEN then user has to get an e-mail. I am doing this because we need to run this script on several test envs, which has different port number. I am trying not to hard code the port # in the script, make it env independent.

Thanks,
Lalitha.

Additional info :

When I do this in my script :
more default.cfg |egrep
-e "WEB_SERVER_PORT|TOMCAT_PORT|CW_RMIREGISTRY_URL local
host:" > /export/home/$USR/***/portfile

portfile has entried like :

WEB_SERVER_PORT 8087
TOMCAT_PORT 8047
CW_RMIREGISTRY_URL localhost:1117

I need my script to take the numbers fromhere and check in netstat -a and check for LISTEN.

Any ideas or help

Thanks,
Gundu

NO Reply so far. Need help.

Gundu

gundu,

Please review the rules.

Bumping posts is not permitted - and you only waited 1hr 34mins before stating that you had no reply. If somebody can help you, they will.

Thanks,
ZB