Search: GO!
        

Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in /www/docs/newdisk/www/docs/rpvsoftware.com/public_html/viewexample.php on line 49
Home > Usage Examples
Awk #2
This example shows how to prepare a report using AWK programming language & RPV Reports.

This easy Awk program generates an RPV file containing the current environment for Unix.

Please observe that newline (\n) has two backslashes. Remember that we're working in Unix.

How to run this
1- Place this program and name it with anyname.awk

2- Execute the following command at the prompt:
# set | awk -f anyname.awk > /tmp/rpvqueue/settings.rpv

Please note that the output of Awk is a file placed in /tmp/rpvqueue. That will be the queue directory and the server must be active and searching there.

Something better you can do
# set | awk -f anyname.awk > settings.rpv;mv settings.rpv /tmp/rpvqueue

In this case we're generating the file first and after that we're moving it to the queue directory. This would be the proper way.
Code
BEGIN {FS = "="

    print "report_title=unix environment (example with awk)"
    print "$1=400"
    print "$2=4000"
    print "[header]"
    print "{f=arial;s=10}"
    print "{spacing=600;\n}"
    print "{b=y;u=y;$1} Variable {$2} Value {b=n;u=n;\n;\n}"
    print "[data]"}
    {

        print "{$1} " $1 " {$2}= " $2 "{\n}"

    }