• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

nawk functionality (API) in java?

 
                  
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
Can anyone tell me if there is a java api that duplicates the functionality provided in the Nawk utility? I am trying to retrieve Unix Server statisitics, reformat the output and load that file into Oracle. I am using the unix sar command to read a system accounting file (named sa24 created on Oct 24) located in /usr/adm/sa. I pipe the output to nawk and use the C printf program to format the output. I have a sample someone else wrote in Korn shell, but I do not know Korn shell and would like to do the same thing in a java program. Some manipulation that needs to be done to the output is delete lines with spaces, header lines and a row showing averages to load just the raw data (numbers) into each Oracle record.
Here is the syntax for what I described above.
sar -u -f sa24|nawk '{printf "%5s %5s %5s %5s %5s\n",$1,$2,$3,$4,$5}'\
Sample output:
SunOS cero 5.8 Generic_108528-13 sun4u

00:00:01 %usr %sys %wio %idle
01:00:00 17 7 40 36
..
{the output includes statistics for every hour}
....
23:00:00 2 7 68 23

Average 11 8 59 22
I found an api for Java that dupicates the printf C functionality at
http://sharkysoft.com/software/java/printf/docs/javadocs/.
Any feedback would be greatly appreciated.
Thank you
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic