Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Help with understanding this regex in a Perl script parsing a 'complex' string Post 303035080 by RudiC on Tuesday 14th of May 2019 03:36:54 AM
Old 05-14-2019
My perl is non-existent, so no help possible here. But - why not a simple awk solution, like
Code:
awk '
match ($4, "SERVICE_NAME=" SRV) {if (match ($4, /PROGRAM=[^)]*/)) P  = substr ($4, RSTART, RLENGTH)
                                 if (match ($4, /USER=[^)]*/))    U  = substr ($4, RSTART, RLENGTH)
                                 if (match ($4, /HOST=[^)]*/))    H  = substr ($4, RSTART, RLENGTH)
                                 if (match ($6, /HOST=[^)]*/))    IP = substr ($6, RSTART, RLENGTH)
                                 print P, H, U, IP
                                }
' SRV="fail_app" OFS="\t" file2
PROGRAM=C:\Windows\system32\exec01.exe    HOST=MNLAPP01    USER=!sysadmin01    HOST=10.11.11.123
PROGRAM=C:\Windows\system32\exec02.exe    HOST=MNLAPP01    USER=!sysadmin01    HOST=10.11.11.123
PROGRAM=C:\Windows\system32\exec03.exe    HOST=MNLAPP01    USER=!sysadmin01    HOST=10.11.11.123
PROGRAM=C:\Windows\system32\exec01.exe    HOST=MNLAPP01    USER=!sysadmin01    HOST=10.11.11.123

EDIT: or


Code:
awk '
function chop(FLD, STR)          {if (match ($FLD, STR "=[^)]*")) return substr ($FLD, RSTART, RLENGTH)
                                 }
match ($4, "SERVICE_NAME=" SRV)  {print chop(4, "PROGRAM"), chop(4, "USER"), chop(4,"HOST"), chop(6, "HOST")
                                 }
' SRV="fail_app" OFS="\t" file2


Last edited by RudiC; 05-14-2019 at 05:31 AM..
These 2 Users Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

Parsing a string in PERL

I have an extractfile (with fields delimited by pipes '|') and I want to prepend a counter based on the below requirements: - The counter starts at 3. - The counter increments only if the date (67th field of the extractfile) is different. Below is what I started off with: $cnt=2;... (3 Replies)
Discussion started by: ChicagoBlues
3 Replies

2. Shell Programming and Scripting

Perl Regex string opperation

I'm working on a basic log parser in perl. Input file looks like: len: 120713 foo bar file size of: testdir1/testdir1/testdir1/testdir1/testfile0 is 120713Of course there are tens of thousands of lines... I'm trying to compare the len and filesize values. #!/usr/bin/perl use strict; use... (2 Replies)
Discussion started by: dkozel
2 Replies

3. Shell Programming and Scripting

Need help understanding perl script error

I solicited this site earlier this week and got a good answer for a perl Script so I made this script from what understood from the answers But now I have a bug and I'm stump. It doesn't parse correctly the Output it stays on the first line My $f2 and reprints in a endless loop I'm sure there... (3 Replies)
Discussion started by: Ex-Capsa
3 Replies

4. Shell Programming and Scripting

Perl REGEX - How do extract a string in a line?

Hi Guys, In the following line: cn=portal.090710.191533.428571000,cn=groups,dc=mp,dc=rj,dc=gov,dc=br I need to extract this string: portal.090710.191533.428571000 As you can see this string always will be bettween "cn=" and "," strings. Someone know one regular expression to... (4 Replies)
Discussion started by: maverick-ski
4 Replies

5. Shell Programming and Scripting

Perl: Regex, string matching

Hi, I've a logfile which i need to parse and get the logs depending upon the user input. here, i'm providing an option to enter the string which can be matched with the log entries. e.g. one of the logfile entry reads like this - $str = " mpgw(BLUESOAPFramework):... (6 Replies)
Discussion started by: butterfly20
6 Replies

6. UNIX for Dummies Questions & Answers

Use Regex to identify / format a complex string

First of all, please have mercy on me. I am not a noob to programming, but I am about as noob as you can get with regex. That being said, I have a problem. I've got a string that looks something like this: Publication - Bob M. Jones, Tony X. Stark, and Fred D. Man, \"Really Awesome Article... (1 Reply)
Discussion started by: egill
1 Replies

7. Shell Programming and Scripting

Complex Regex Perl

Hi the below perl snippet will replace any three letter string in the beginning with a two letter string which is specified..but if i want to modfiy only certain characters for eg.. ABC - AB CAB - AB AAA - No Modifcations 1AB - AB AB8 - AB Whatever coming before or after of AB only have... (2 Replies)
Discussion started by: rajkrishna89
2 Replies

8. Shell Programming and Scripting

perl regex string match issue..kindly help

i have a script in which i need to skip comments, and i am able to achieve it partially... IN text file: {**************************** {test : test...test } Script: while (<$fh>) { push ( @data, $_); } if ( $data =~ m/(^{\*+$)/ ){ } With the above match i am... (5 Replies)
Discussion started by: avskrm
5 Replies

9. Shell Programming and Scripting

Parsing expect_out using regex in expect script

Hi, I am trying to write an expect script. Being a newbie in expect, maybee this is a silly doubt but i am stuck here. So essentially , i want the o/p of one router command to be captured . Its something like this Stats Input Rx : 1234 Input Bytes : 3456 My expect script looks ... (5 Replies)
Discussion started by: ashy_g
5 Replies

10. Shell Programming and Scripting

Help understanding perl script

Hello, A former sys admin placed this script on one of our boxes and it needs to be adjusted, but I'm not familiar with perl. Can someone help break this down for me? I'm particularly interested in the -mtime function. What's the time frame being referenced here. ... (5 Replies)
Discussion started by: bbbngowc
5 Replies
Balsa(1)							       2.0.6								  Balsa(1)

NAME
Balsa - the GNOME email client. SYNOPSIS
balsa [--help] [--version] [-c] [--checkmail] [-m USER@HOST.TLD] [--compose=USER@HOST.TLD] [-a FILENAME] [--attach=FILENAME] [-o MAILBOX] [--open-mailbox=MAILBOX] [-u] [--open-unread-mailbox] [-d] [--debug-pop] DESCRIPTION
Balsa is an e-mail reader. This client is part of the GNOME desktop environment. It supports local mailboxes, POP3 and IMAP. For help on using Balsa, see the program documentation in the help menu. OPTIONS
-c, --checkmail Balsa will immediately check for new mail when the program is launched -i, --open-inbox Balsa will open the Inbox on startup. -m USER@HOST.TLD, --compose=USER@HOST.TLD When invoked with this option, balsa will open a new message with the specified address in the To: field. The parameter can be spec- ified also in URL format - it makes it possible to use balsa as mailto protocol handler by setting the mailto protocol command to balsa -m "%s" in URL handlers section of GNOME control center. -a FILENAME, --attach=FILENAME When invoked with this option, balsa will open a new message with the specified file already attached to the message. -o MAILBOX, --open-mailbox=MAILBOX Balsa will open automatically at startup the mailbox or mailboxes specified on the command line with this option. Multiple mail- boxes are delimited by semicolons. -u, --open-unread-mailbox Open the first unread mailbox when balsa is launched. -d, --debug-pop Dumps the POP3 communication to stderr. Useful for debugging POP3 connections. WEBSITE
http://balsa.gnome.org/ SUGGESTIONS AND BUG REPORTS
Any bugs found should be reported to the Balsa Developer mailing list at balsa-list@gnome.org or you may want to make use of the online bug-tracking system available on the web at http://bugzilla.gnome.org/. See http://balsa.gnome.org/bugs.html for more information on reporting bugs. Before reporting bugs, please check to see if the bug is mentioned in the FAQ's or the mailing list archive. See the section on Other Info for locations of these. When reporting Balsa bugs, it is important to include a reliable way to reproduce the bug, version number of Balsa (as well as GTK and GNOME), OS name and version, and any relevant hardware specs. If a bug is causing a crash, it is very useful if a stack trace can be provided. And of course, patches to rectify the bug are even better. AUTHORS
See the AUTHORS file included with Balsa, probably at /usr/share/doc/balsa-2.0.6/AUTHORS FILES
~/.gnome2/balsa Balsa's preferences file. ~/.gnome2_private/balsa Balsa's POP and IMAP passwords file. SEE ALSO
mailcap(5) metamail(1) sendmail(8) COPYRIGHT
(c) 1997-2003 Stuart Parmenter and others, see AUTHORS for a list of people. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, pro- vided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in sup- porting documentation. Version 03 January 2003 Balsa(1)
All times are GMT -4. The time now is 10:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy