Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gawk vs Awk (help)

Status
Not open for further replies.

gophertee

Programmer
Oct 11, 2000
27
US
Ok I went to and found some Ftp sites. I downloaded Gawk so that I can upload it to our Awk. How do I do this? Are there instructions on how to upload this?

Questios I pose: If I upload this, will it affect any code or libraries we currently are using on the Unix box?

History: We are using AIX and apparently our version of AIX doesn't support Hex Null characters; /\x000/ will not work. Unfortunately the AIX version of awk will not pick that off. Thus the reason why I was told to download GAWK. Now (scratching my head and feeling a headache coming on) I am trying to trap null characters showing up. Below is the code we currently are using: Someone earlier said to use Octal Nulls($0 ~ /\000/)system(sys_call);exit. Where would I put this. Also someone said when I upload GAWK I should put this in my code: where???
gsub(/\000/,"") #all nulls in each line
$0=$0 #reset fields if necessary



#! /usr/bin/awk

###########################################################################
#
# Script name trans_scrubdata.awk
# Purpose: To find records in the transmission files that are not of
# the proper length or have unprintable chars in them and move
# those files to the bad data directory.
# Date written: 05/25/2000
# Modification History:
#
###########################################################################

BEGIN {
getline rec_in_1 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
getline rec_in_2 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
getline rec_in_3 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
getline rec_in_4 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
getline rec_in_5 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
getline rec_in_6 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
getline rec_in_7 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
getline rec_in_8 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
getline rec_in_9 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
getline rec_in_10 < &quot;/usr/acct/acmmgr/EXTRMT.IN&quot;;
rec_type_7 = substr(rec_in_7, 24, 2);
rec_type_8 = substr(rec_in_8, 24, 2);
rec_type_9 = substr(rec_in_9, 24, 2);
rec_type_10 = substr(rec_in_10, 24, 2);
rec_len7 = substr(rec_in_7, 46, 3);
rec_len8 = substr(rec_in_8, 46, 3);
rec_len9 = substr(rec_in_9, 46, 3);
rec_len10 = substr(rec_in_10, 46, 3);
close(&quot;/usr/acct/acmmgr/EXTRMT.IN&quot;);
}
{
# sys_call = &quot;mv &quot; FILENAME &quot; /usr/rec/saleswork/saleshold/&quot; FILENAME &quot;.`date '+%j%H%M%S'`&quot;;
sys_call = &quot;mv &quot; FILENAME &quot; &quot; FILENAME &quot;.`date '+%j%H%M%S'`&quot;;
if (/[^A-Za-z0-9 \t!@#$%^&*\(\)\&quot;\'\/.,;:]\r/) {
print sys_call;
system(sys_call);
exit 0;
}

print &quot;rec type is &quot; substr($0,1,2);
if (substr($0,1,2) == rec_type_7) {
print &quot;rec length supposed to be &quot; rec_len7;
print &quot;rec length is &quot; length($0);
if (length($0) != (rec_len7 - 1)) {
print sys_call;
system(sys_call);
exit 0;
}
}
if (substr($0,1,2) == rec_type_8) {
print &quot;rec length supposed to be &quot; rec_len8;
print &quot;rec length is &quot; length($0);
if (length($0) != rec_len8 - 1) {
print sys_call;
system(sys_call);
exit 0;
}
}
if (substr($0,1,2) == rec_type_9) {
print &quot;rec length supposed to be &quot; rec_len9;
print &quot;rec length is &quot; length($0);
if (length($0) != rec_len9 - 1) {
print sys_call;
system(sys_call);
exit 0;
}
}
if (substr($0,1,2) == rec_type_10) {
print &quot;rec length supposed to be &quot; rec_len10;
print &quot;rec length is &quot; length($0);
if (length($0) != rec_len10 - 1) {
print sys_call;
system(sys_call);
exit 0;
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top