The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Variables scope. dinjo_jo Shell Programming and Scripting 13 09-10-2008 07:03 AM
Doubt??? [scope of variables] qzv2jm Shell Programming and Scripting 1 03-04-2008 09:19 AM
How to access variables across scripts javaDev Shell Programming and Scripting 1 08-13-2007 04:47 AM
Access Awk Variables Outside Scope Amruta Pitkar UNIX for Advanced & Expert Users 2 10-26-2006 09:35 PM
Read variables from Access table Sn33R UNIX for Dummies Questions & Answers 2 09-24-2003 01:01 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-26-2006
Amruta Pitkar Amruta Pitkar is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 54
Access Awk Variables Outside Scope

My awk script searches for specified patterns in a text file and stores these values into mem variables.
Once this is done I want to Insert these values into a table.

How can I avail of the variable values outside the scope of awk script....

One method that I have tried is to write the variables values into a temp file with delimiters and then read these values from a shell script, form a connection to database and insert the values into table....But I feel this is doing things in a roundabout way....

What wud be a straighter approach ? I dont want to sacrifice the awk script !

The awk script now :

Code:
/Total logical records skipped:/ {skiprecs=$5;}
/Total logical records read:/ {readrecs=$5;}
/Total logical records rejected:/ {rejectrecs=$5;}
/Total logical records discarded:/ {discardrecs=$5}
END { totalfailrecs = skiprecs + rejectrecs + discardrecs ;
      totalsuccessrecs = readrecs ;
      totalrecs = totalfailrecs + totalsuccessrecs ;
      printf "Printing the results "
      printf ("\n")
      printf ("Failed Records : %d\n", totalfailrecs);
      printf ("Success Records : %d\n", totalsuccessrecs);
      printf ("Total Records : %d\n", totalrecs);
      printf ("%d,%d,%d",totalfailrecs,totalsuccessrecs,totalrecs)>>"tempfile"
    }
Thanks
Amruta Pitkar
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0