Sponsored Content
Top Forums Shell Programming and Scripting Parsing a $VARIABLE within a script. Post 302705867 by Don Cragun on Tuesday 25th of September 2012 04:05:23 PM
Old 09-25-2012
The simple answer is "Yes." You can do all of that. But, to figure out what needs to be done here, we need to know a lot more about the format of the string referenced by $EVENTMSG and we need to know what you want out of $EVENTMSG besides the substring that follows AlarmSeverity=.
This User Gave Thanks to Don Cragun For This Post:
 

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
pfmt(3C)						   Standard C Library Functions 						  pfmt(3C)

NAME
pfmt - display error message in standard format SYNOPSIS
#include <pfmt.h> int pfmt(FILE *stream, long flags, char *format, ... /* arg */); DESCRIPTION
The pfmt() retrieves a format string from a locale-specific message database (unless MM_NOGET is specified) and uses it for printf(3C) style formatting of args. The output is displayed on stream. The pfmt() function encapsulates the output in the standard error message format (unless MM_NOSTD is specified, in which case the output is similar to printf()). If the printf() format string is to be retrieved from a message database, the format argument must have the following structure: <catalog>:<msgnum>:<defmsg>. If MM_NOGET is specified, only the defmsg field must be specified. The catalog field is used to indicate the message database that contains the localized version of the format string. This field must be limited to 14 characters selected from the set of all characters values, excluding (null) and the ASCII codes for / (slash) and : (colon). The msgnum field is a positive number that indicates the index of the string into the message database. If the catalog does not exist in the locale (specified by the last call to setlocale(3C) using the LC_ALL or LC_MESSAGES categories), or if the message number is out of bound, pfmt() will attempt to retrieve the message from the C locale. If this second retrieval fails, pfmt() uses the defmsg field of the format argument. If catalog is omitted, pfmt() will attempt to retrieve the string from the default catalog specified by the last call to setcat(3C). In this case, the format argument has the following structure: :<msgnum>:<defmsg>. The pfmt() will output Message not found!! as format string if catalog is not a valid catalog name, if no catalog is specified (either explicitely or with setcat()), if msgnum is not a valid number, or if no message could be retrieved from the message databases and defmsg was omitted. The flags argument determine the type of output (such as whether the format should be interpreted as is or encapsulated in the standard message format), and the access to message catalogs to retrieve a localized version of format. The flags argument is composed of several groups, and can take the following values (one from each group): Output format control MM_NOSTD Do not use the standard message format, interpret format as printf() format. Only catalog access control flags should be specified if MM_NOSTD is used; all other flags will be ignored. MM_STD Output using the standard message format (default value 0). Catalog access control MM_NOGET Do not retrieve a localized version of format. In this case, only the defmsg field of the format is specified. MM_GET Retrieve a localized version of format from the catalog, using msgid as the index and defmsg as the default message (default value 0). Severity (standard message format only) MM_HALT Generate a localized version of HALT, but do not halt the machine. MM_ERROR Generate a localized version of ERROR (default value 0). MM_WARNING Generate a localized version of WARNING. MM_INFO Generate a localized version of INFO. Additional severities can be defined. Add-on severities can be defined with number-string pairs with numeric values from the range [5-255], using addsev(3C). The specified severity will be generated from the bitwise OR operation of the numeric value and other flags If the sever- ity is not defined, pfmt() uses the string SEV=N, where N is replaced by the integer severity value passed in flags. Multiple severities passed in flags will not be detected as an error. Any combination of severities will be summed and the numeric value will cause the display of either a severity string (if defined) or the string SEV=N (if undefined). Action MM_ACTION Specify an action message. Any severity value is superseded and replaced by a localized version of TO FIX. STANDARD ERROR MESSAGE FORMAT
The pfmt() function displays error messages in the following format: label: severity: text If no label was defined by a call to setlabel(3C), the message is displayed in the format: severity: text If pfmt() is called twice to display an error message and a helpful action or recovery message, the output can look like: label: severity: textlabel: TO FIX: text RETURN VALUES
Upon success, pfmt() returns the number of bytes transmitted. Upon failure, it returns a negative value: -1 Write error to stream. EXAMPLES
Example 1: Example of pfmt() function. Example 1: setlabel("UX:test"); pfmt(stderr, MM_ERROR, "test:2:Cannot open file: %s ", strerror(errno)); displays the message: UX:test: ERROR: Cannot open file: No such file or directory Example 2: setlabel("UX:test"); setcat("test"); pfmt(stderr, MM_ERROR, ":10:Syntax error "); pfmt(stderr, MM_ACTION, "55:Usage ... "); displays the message UX:test: ERROR: Syntax error UX:test: TO FIX: Usage ... USAGE
Since it uses gettxt(3C), pfmt() should not be used. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-safe | +-----------------------------+-----------------------------+ SEE ALSO
addsev(3C), gettxt(3C), lfmt(3C), printf(3C), setcat(3C), setlabel(3C), setlocale(3C), attributes(5), environ(5) SunOS 5.10 29 Dec 1996 pfmt(3C)
All times are GMT -4. The time now is 12:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy