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 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_2 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_3 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_4 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_5 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_6 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_7 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_8 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_9 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_10 < "/usr/acct/acmmgr/EXTRMT.IN";
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("/usr/acct/acmmgr/EXTRMT.IN"
}
{
# sys_call = "mv " FILENAME " /usr/rec/saleswork/saleshold/" FILENAME ".`date '+%j%H%M%S'`";
sys_call = "mv " FILENAME " " FILENAME ".`date '+%j%H%M%S'`";
if (/[^A-Za-z0-9 \t!@#$%^&*\(\)\"\'\/.,;:]\r/) {
print sys_call;
system(sys_call);
exit 0;
}
print "rec type is " substr($0,1,2);
if (substr($0,1,2) == rec_type_7) {
print "rec length supposed to be " rec_len7;
print "rec length is " 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 "rec length supposed to be " rec_len8;
print "rec length is " 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 "rec length supposed to be " rec_len9;
print "rec length is " 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 "rec length supposed to be " rec_len10;
print "rec length is " length($0);
if (length($0) != rec_len10 - 1) {
print sys_call;
system(sys_call);
exit 0;
}
}
}
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 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_2 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_3 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_4 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_5 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_6 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_7 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_8 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_9 < "/usr/acct/acmmgr/EXTRMT.IN";
getline rec_in_10 < "/usr/acct/acmmgr/EXTRMT.IN";
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("/usr/acct/acmmgr/EXTRMT.IN"
}
{
# sys_call = "mv " FILENAME " /usr/rec/saleswork/saleshold/" FILENAME ".`date '+%j%H%M%S'`";
sys_call = "mv " FILENAME " " FILENAME ".`date '+%j%H%M%S'`";
if (/[^A-Za-z0-9 \t!@#$%^&*\(\)\"\'\/.,;:]\r/) {
print sys_call;
system(sys_call);
exit 0;
}
print "rec type is " substr($0,1,2);
if (substr($0,1,2) == rec_type_7) {
print "rec length supposed to be " rec_len7;
print "rec length is " 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 "rec length supposed to be " rec_len8;
print "rec length is " 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 "rec length supposed to be " rec_len9;
print "rec length is " 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 "rec length supposed to be " rec_len10;
print "rec length is " length($0);
if (length($0) != rec_len10 - 1) {
print sys_call;
system(sys_call);
exit 0;
}
}
}