- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: open a logoutput and filter it.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2004 08:25 AM
тАО09-27-2004 08:25 AM
open a logoutput and filter it.
How can I open a oputput file and how can filter contents in way in the file attached described:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2004 09:27 AM
тАО09-27-2004 09:27 AM
Re: open a logoutput and filter it.
You open the files with:
OPEN logical-name filename
When you open a file for writing you use the /WRITE or /APPEND qualifier (write for new file and append for appending to end of an existing file).
When you open a file for reading use the /READ qualifier.
So if yours attached file is a log file named logfile.log, you open it with:
OPEN/READ mylog logfile.log
Now you can read it with the READ command.
To filter the contents you must write a procedure like this:
$ OPEN/READ LOG logfile.log ! substitute the name with a full name to yours logfile
$ OPEN/WRITE FILT filtered.log ! same as previous line
$L1:
$ MSISDN=""
$ STATUS=""
$ ACC_TIME=""
$ SMS_TEXT=""
$L2:
$ READ LOG LINE/END=END
$ IF F$EXTRACT(0,13,LINE).EQS."Input MSISDN:"
$ THEN
$ MSISDN=F$ELEMENT (1,":",LINE)
$ GOTO L2
$ ENDIF
$!repeat the if for each line you are interested.
$!the last test is a litle different
$ IF F$EXTRACT(0,11,LINE).EQS."Accept time"
$ THEN
$ ACC_TIME=F$ELEMENT (1,":",LINE)
$ GOTO WRITE_OUT
$ ENDIF
$ GOTO L2 !Line is not interesting.
$WRITE_OUT:
$ WRITE FILT F$FAO("!20AS !10AS !14AS !AS",MSISDN,STATUS,ACC_TIME,SMS_TEXT)
$!play with the lengths to get the right output
$ GOTO L1
$END:
$ CLOSE LOG
$ CLOSE FILT
This is only one possible approach, there are many other posibilities.
When you write a procedure you will need lexical functions (F$something). Do a HELP LEXICAL for help on them. You can also look to the HP OpenVMS DCL Dictionary:
http://h71000.www7.hp.com/doc/732FINAL/9996/9996PRO.HTML
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2004 10:21 AM
тАО09-27-2004 10:21 AM
Re: open a logoutput and filter it.
You can probably simplify the task by prefiltering the file with SEARCH. I'm not certain where all your output fields come from, but this may be a reasonable start:
$ SEARCH yourfile.log " at ","Input ", "result","Accept time"
Add additional keywords to include more lines from the input file. If you're running V7.2 or above, you can also PIPE
SEARCH commands together. For example:
$ PIPE SEARCH yourfile.log -
" at ","Input ", "result","Accept time" | -
SEARCH SYS$PIPE "%x" /MATCH=NOR
the first SEARCH will include matching lines in the output, the second will exclude some of those. It's all a matter of selecting the appropriate keywords to identify certain lines. For example, I've chosen " at " because it preceeds all your dates in output lines.
This may make your final processing simpler. You can even pipe the final stage of the SEARCH into your procedure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2004 10:59 AM
тАО09-27-2004 10:59 AM
Re: open a logoutput and filter it.
I like perl for these kind of jobs.
Something along the lines of:
$format = "%-12s %-12s %-14s %-17s\n";
printf $format, "MSISDN:", "Status:", "Accepted Time:", "SMS Text:";
printf $format, "------------","------------","--------------","------------------";
while (<>) {
$MSISDN = $1 if (/Input MSISDN:\s(\w+)/);
$SMtext = $1 if (/Enter SM text :\s*(.*)$/);
$Status = $1 if (/Submit result\s+\w+\s*\w+\s+:\s+\d+,\s+(.*)$/);
if (/Accept time\s+:\s+(\d+)/) {
printf $format, $MSISDN, $Status, $1, $SMtext;
$MSISDN = $Status = $SMtext = "-";
}
}
See the structure?
- Set up some formating rules, and print header
- Loop through file
- Stash away specific matches (strings in paratheses)
- Print result on final match
- Clear other matches 'just in case'
- loop
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2004 05:50 PM
тАО09-27-2004 05:50 PM
Re: open a logoutput and filter it.
I created the file as u write and and run the file @file.com a FILTER.LOG is created but nothing contain . the file to be filtered I called logfile.log as in your script. Please have a look.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2004 06:04 PM
тАО09-27-2004 06:04 PM
Re: open a logoutput and filter it.
I tried your sugestion about formating.
THe file can be filtered first and than I can format? also I dont see which file is formated or I'm wrong? SEE the printout reasul attached.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2004 06:24 PM
тАО09-27-2004 06:24 PM
Re: open a logoutput and filter it.
The procedure in my previous post was just an example. I dont know why it is not working with jours log file. I can make only some suppositions.
First, the name of yours log file can be anything, but it must point right to the log file. So replace my logfile.log with a full file specification of yours log file.
Inspect the contents of yours logfile (with an editor or with type) and see what is the content of the lines you are interested. The Ifs must match the contents. So you must modify the f$extract and the contents of the string inclused in "". The f$extract lexical function, extracts a substring from a string (which is the third parameter) the first parameter is the starting position (0 is the first character) and the second parameter is the length of the substring. Please se more by typing help lexicals f$extract.
You can debug the procedure by typing
$ SET VERIFY
before running the command procedure. This will display each executed line. ($ SET NOVERIFY to stop displaying). Also you can add some show symbol to the command procedure.
And try Johns solution, maybe it will be more simple for you.
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-28-2004 01:36 AM
тАО09-28-2004 01:36 AM
Re: open a logoutput and filter it.
I just used 'word' to save your first attachement as text.
Then I use that as input for the perl script I showed.
Results:
$ crea test.pl
$format = "%-12s %-12s %-14s %-17s\n";
printf $format, "MSISDN:", "Status:", "Accepted Time:", "SMS Text:";
printf $format, "------------","------------","--------------","----------------
--";
while (<>) {
$MSISDN = $1 if (/Input MSISDN:\s(\w+)/);
$SMtext = $1 if (/Enter SM text :\s*(.*)$/);
$Status = $1 if (/Submit result\s+\w+\s*\w+\s+:\s+\d+,\s+(.*)$/);
if (/Accept time\s+:\s+(\d+)/) {
printf $format, $MSISDN, $Status, $1, $SMtext;
$MSISDN = $Status = $SMtext = "-";
}
}
Exit
$ perl test.pl < test.txt
MSISDN: Status: Accepted Time: SMS Text:
------------ ------------ -------------- ------------------
355692223557 Success 04092715141856 Site #10 MTX is out of service. NMC
355692223557 Success 04092715231956 SITEOOS
355692223557 Success 04092715374556 TEST
355692223557 Success 04092715374956 TEST
Close to what you need?
Hein.