HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Can someone help me parse this file?
Operating System - HP-UX
1829465
Members
1616
Online
109991
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
05-25-2005 08:37 AM
05-25-2005 08:37 AM
Re: Can someone help me parse this file?
Here is what I tend to use:
$file = shift @ARGV or die "Please provide parameter file name argument"
This takes the first argumentafter the perl program away from the ARGV array and sticks it in $file.
So if you had a second argument, maybe some counter, then you can repeat that and the next line could be:
$counter = shift @ARGV or die "Please provide counter value as argument"
In a simple one-liner which will 'cat' a file:
perl -e '$file=shift @ARGV or die "Please provide parameter file name argument"; open (X,$file) or die "open problem $file"; print while (
And a second argument can turn it into a 'head' function:
perl -e '$file=shift @ARGV || die "file name?"; $count=shift @ARGV || die "counter?"; open (X,$file) or die "open $file ?"; while (
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2005 09:57 AM
05-25-2005 09:57 AM
Re: Can someone help me parse this file?
I don't understand...
How do you integrate that in comparsion to the command initially provided?
ps -fu | perl tux.p
The tux.p perl program would contain in instead what for the first 3 lines that were originally provided?
$file = "";
$format = "%15s |%10s |%4s |%4s |%4s |%4s |%s\n";
open (TUX,"<$file") or die "Could not open $file";
Thanks!
MAD
How do you integrate that in comparsion to the command initially provided?
ps -fu
The tux.p perl program would contain in instead what for the first 3 lines that were originally provided?
$file = "
$format = "%15s |%10s |%4s |%4s |%4s |%4s |%s\n";
open (TUX,"<$file") or die "Could not open $file";
Thanks!
MAD
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2005 11:37 AM
05-25-2005 11:37 AM
Re: Can someone help me parse this file?
Old line with hard-coded file name:
$file = "
To be replaced with new line:
$file = shift @ARGV or die "Please provide parameter file name argument"
That's all.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2005 06:21 PM
05-25-2005 06:21 PM
Re: Can someone help me parse this file?
Adam,
I was out for a few days so couldn't work on the script. I have finished it now and its attached "wrapper.ksh". The awk parser script "parse.awk" called from within the wrapper is pasted below. Just run the wrapper script on the command line as follows:
# wrapper.ksh
Let me know if you run into problems and i'll be happy to tweak it.
cheers!!!
===============parse.awk=====================
# strops function
function strops(input, words, n)
{
n = split(input, words, "=")
return words[n]
}
# main routine
BEGIN {
RS=""; OFS="|"
} /^service/ {
print $1,
strops($2),
strops($3),
strops($4),
strops($5)
}
=============================================
I was out for a few days so couldn't work on the script. I have finished it now and its attached "wrapper.ksh". The awk parser script "parse.awk" called from within the wrapper is pasted below. Just run the wrapper script on the command line as follows:
# wrapper.ksh
Let me know if you run into problems and i'll be happy to tweak it.
cheers!!!
===============parse.awk=====================
# strops function
function strops(input, words, n)
{
n = split(input, words, "=")
return words[n]
}
# main routine
BEGIN {
RS=""; OFS="|"
} /^service/ {
print $1,
strops($2),
strops($3),
strops($4),
strops($5)
}
=============================================
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP