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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple script but it's making me crazy

Status
Not open for further replies.

icu812

MIS
Sep 10, 2001
52
0
0
US
Input script (oradbproc3.lis)looks like this:
sp18cw:tnslsnr TRN::The DB Listener process on SP18 is down:
sp18cw:FNDLIBR:appltrn:The TRN Concurrent Manager process on SP18 is down:

Korn shell script looks like this:
for line in `cat /bin/danka/oradbproc3.lis`
do
SERVER=`echo "$line"|cut -f 1 -d :`
PROC=`echo "$line"|cut -f 2 -d :`
USER=`echo "$line"|cut -f 3 -d :`
MAILMSG=`echo "$line"|cut -f 4 -d :`
echo $SERVER
done

My problem is that the cut command does not seem to be working as it should. Anyone got any suggestions before I decide to quit this business and open up a hot dog stand somewhere???(Just kiddin, it's not that bad...yet) Thanks
 
Not sure what you're trying to achieve here but anyhoo.....

I hate the 'for line in' construct' as my brain can't seem to get round the logic of what its doing, so I rewrite the script as;

cat oradbproc3.lis | while read LINE
do
SERVER=`echo $LINE|cut -f1 -d :`
PROC=`echo $LINE|cut -f2 -d :`
USER=`echo $LINE|cut -f3 -d :`
MAILMSG=`echo $LINE|cut -f4 -d :`
echo $SERVER " " $PROC " " $USER " " $MAILMSG
done

This gives the result;

sp18cw tnslsnr TRN The DB Listener process on SP18 is down
sp18cw FNDLIBR appltrn The TRN Concurrent Manager process on SP18 is down

Is that the sort of thing you were after ?

Alex

 
Personally I would use awk or perl rather than the "echo|cut" combo. Just a personal preference.
 
This is exactly what I was looking for. Thanks Alexhu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top