Sponsored Content
Top Forums Shell Programming and Scripting Parsing a $VARIABLE within a script. Post 302707559 by Don Cragun on Saturday 29th of September 2012 02:30:11 AM
Old 09-29-2012
This is a lot to absorb and your last message clears up some of the issues, but I'm still confused about several issues. I think I understand some things now. I assume that:
  1. The 40K+ files named "Event" followed by 8 lowercase hexadecimal digits are templates for 40K+ different types of event messages.
  2. Someplace else there are a bunch (40K+ or less) of SetScript files.
  3. You have a way to get an individual event message stored in a shell variable referenced by $EVENTMESSAGE.
  4. SetScript files or Eventxxxxxxxx files enable some external process to format an external event reported by some piece of hardware or software into an event message using variables that are somehow made available to the environment of that external process.
  5. You showed the following event message in your last posting:
    Code:
    Sep 28, 2012 7:43:57 AM MDT
     
    - An "iddmodAgentDownTrap" event has occurred, from a device designated as type Host_IBMDirector, named lpvd-sqldv01.c.utah.com.
     
    This trap is sent when an Insight agent is detected to be down. It is then resent synchronously with the Alarm traps, every 5 minutes (default frequency) as long as the Insight agent is still detected to be down.
     
    Agent Name = ms2008-default@lpvd-sqldv01
    Agent Type = ms2005
    Agent Status = down

    which is supposed to correspond to Eventxxxxxxxx file "Event01169b15" which says that events of this type are formatted as:
    Code:
    {d "%w- %d %m-, %Y - %T"} - An "iddmodAgentDownTrap" event has occurred, from a device designated as type: {t}, named: {m}. 
     
    This trap is sent when an Insight agent is detected to be down. It is then resent synchronously with the Alarm traps, every 5 minutes (default frequency) as long as the Insight agent is still detected to be down. 
     
    Agent Name = {S 1} 
    Agent Type = {S 3} 
    Agent Status = {T iddmodAlarmSummaryUpDown 4}

    but the 1st line of Event01169b15 turned into three lines in the event message. I believe the two extra newlines were a cut and paste error and would not appear in an actual event message.
  6. In message #6 in this thread you showed a SetScript that contained the line:
    Code:
    echo "Server Instance Error: " $SI

    but showed the corresponding line in the event message to be:
    Code:
    Server Instance: 31415

    I assume it was another cut and paste error that caused " Error" to be in the SetScript file but not in the event message.
Are the above assumptions correct?

When your script is called will it always be given a single event message stored in the variable $EVENTMESSAGE, or is it given a file from which it reads multiple event messages? Is there any way for your program to determine which Eventxxxxxxxx file is associated with an event message?
Is there any way to determine which SetScript file is associated with an Eventxxxxxxxx file? Is there any way to determine which SetScript file is associated with a given event message?

And, again, more concretely, and most importantly, assuming that one of your scripts is called with EVENTMESSAGE set to:
Code:
Sep 27,2012 09:03:08 PM - A "LiveHealthAlarm" event has occurred, from SwCiscoIOS device, named co-lpvi-6509-Q67-1.c.utah.com.
 
eHealth Alarm Start Time - Sep 27,2012 09:03:08 PM
eHealth Alarm Occurrence - 305954
Element Name - co-lpvi-6509-Q67-1.c.utah.com-RH
Element Alias - co-lpvi-6509-Q67-1.c.utah.com-RH
Profile - _Router or Switch - Failure
Exception Type - basicEvent
Description - Generic Syslog message
eHealth Alarm ID - 1000042

exactly what output do you want your script to produce? And, does your script know which Eventxxxxxxxx file and which SetScript file are associated with that event?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing a variable string

Hi all, I have a problem surfacing and I hope you all could help. What I have to do is take a input file and fill out a fax template from that file. The biggest problem I found was I have to parse the string "//FAX(faxnumber=555-5555;style="style1"; and on and on. The string can be in any... (5 Replies)
Discussion started by: pageld
5 Replies

2. UNIX for Dummies Questions & Answers

Parsing a variable length record

I need to pick a field out of a variable record - the field is always found 4 fields after a certain text string, but it can be on any line of the record and in any position across the record on a line. I have had no luck through any of the Unix editors being able to cut a field that isn't always... (17 Replies)
Discussion started by: Barb
17 Replies

3. Shell Programming and Scripting

parsing a string into variable

I know solution to this but I was wondering if its easier than what i think I have to pass 20 parameters to a script, which of course is not working so I parsed $3 to be a pipe deliminated string for instance below a.ksh One Two Compa|Compb|Compc|compd|............. Now i have to read... (5 Replies)
Discussion started by: Anubhav
5 Replies

4. Shell Programming and Scripting

parsing a variable

Hi, I want to get an input from user and parse the input. The legal characters allowed in the input are alnum(a-zA-Z0-0), . , - Also the first and las characters must be alnum only. e.g if the input is abc.ghh-sok.com then the script should return correct, and if the input is like... (2 Replies)
Discussion started by: g_rohit7
2 Replies

5. Shell Programming and Scripting

Parsing a variable length file

Hi I am new to shell scripting. I need to parse a file which contains the header and detail records and split into n of file based on dept ID, for ex. INPUT FILE: DEPT ID: 1 EMPNAME: XYZ EMPAddress: XYZZZ DEPT ID: 2 EMPNAME: ABC EMPAddress: ABCD DEPT ID: 1 EMPNAME: PQR EMPAddress:... (6 Replies)
Discussion started by: singhald
6 Replies

6. UNIX for Dummies Questions & Answers

Parsing a variable

Can someone help me? I have been looking in the archives as I am sure this is very simple to do, but I do not know. I have a variable which sometimes contains a file name and sometimes contains a fully qualified file name. I want to be able to separate the directory from the file name into 2... (3 Replies)
Discussion started by: CAGIRL
3 Replies

7. Shell Programming and Scripting

Parsing file list in variable

Hello, somewhere in a shell script, i am storing the output of "ls" into a variable. My question is how can i parse this variable to get each filepath. I don't want to create a temporary file to write down all the filenames and then parse it.. is there a easy way out.. here is what... (3 Replies)
Discussion started by: prasbala
3 Replies

8. Shell Programming and Scripting

XML parsing with a variable

I have the following XML <Audit_Type>1</Audit_Type><Session_Id>34505863</Session_Id> <StatementId>1</StatementId><EntryId>1</EntryId> <Extended_Timestamp>2012-03-06T10:25:20.789459</Extended_Timestamp> <DB_User>KASINIY</DB_User> <OS_User>majohn1</OS_User><OS_Process>28636</OS_Process>... (3 Replies)
Discussion started by: BeefStu
3 Replies

9. Shell Programming and Scripting

Parsing Output of a Variable

i have a log file that contains something similar to this: one two three four five six seven eight nine ten eleven twelve thirteen fourteen one two three four five six seven eight nine ten eleven twelve thirteen fourteen one two three four five six seven eight nine ten eleven twelve... (3 Replies)
Discussion started by: SkySmart
3 Replies

10. Shell Programming and Scripting

Variable of Path directory is not parsing in awk

Hi All, i had to split one files into 10 equally. For that i have coded below awk. OUTPUT_FILE=/home/sit/path/Files/file_EXPORT.lst DIR_NM=`dirname ${OUTPUT_FILE}` awk -v CURR_DATE="$(date +'%d-%m-%Y-%H-%M')" -v pth=$DIR_NM '{print >> pth/"tgt_file_name"CURR_DATE"_"NR%10 }' ${OUTPUT_FILE} ... (7 Replies)
Discussion started by: looney
7 Replies
All times are GMT -4. The time now is 09:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy