Sponsored Content
Full Discussion: Verifying Record Length
Top Forums Shell Programming and Scripting Verifying Record Length Post 302805833 by SoloXX on Saturday 11th of May 2013 01:10:53 PM
Old 05-11-2013
Linux Verifying Record Length

Hi all,

We are going through a total migration from AIX-based server framework to Linux-based servers. When I am testing *.sh and *.awk in a lower environments, it abends at the same step everytime in verifying the record length of the first row of the source file.

I know this source file is good because I pulled the file from the production environment in which the source file was already processed succesfully. So, I'm thinking the existing script (a header checking process) that was pulled from the existing AIX production server. There are two result options for this script: Good or Problem File.

The error always comes back that there is a "Problem with the source file sent". I'm not a scripter as it's not part of my duties, but the task has fallen onto my team. Wondering if the script below is compatible with Linux server syntax?? ANY insight would be greatly appreciated.


BEGIN {
good_count = 0
bad_count = 0
line_count = 0
}
NR == 1 {
rec_count = substr($0, 15, 8)
date_str = substr($0, 32, 10)

print "Date in Header Record : " date_str
}
NR > 1 {
line_count++

if (length($0) == 710)
{
print $0 > GoodFile
good_count++
}
else
{
print $0 > BadFile
bad_count++
}
}
END {
if ( line_count == rec_count && bad_count==0 )
{
print "********************************************"
print "Count in header : " rec_count
print "Count in file received : " line_count
print " "
print "Number of Good Records : " good_count
print "Number of Bad Records : " bad_count
}
else
{
print "********************************************"
print " PROBLEM WITH FILE SENT FROM SOURCE "
print " "
print "Count in header : " rec_count
print "Count in file received : " line_count
print " "
print "Number of Good Records : " good_count
print "Number of Bad Records : " bad_count
exit 99
}
}

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

fixed record length

hello! I have a file with fixed record length... format: 123445asdfg 4343777 sfgg I wanna convert it to 123445,asdfg ,4343,777 ,sfgg is there any way to do it? sed/grep/awk?? at the moment I use sed -e 's_ \(\)_,\1_g' but it works only if there are spaces between... (16 Replies)
Discussion started by: george_
16 Replies

2. UNIX for Dummies Questions & Answers

Creating new file with new record length

Hi there, using the command below > cat file1 | tr "\001" " " > tmp2 how can I alter the record length of tmp2 to fix length of 350 bytes ? Thanks a lot! (7 Replies)
Discussion started by: mrjunsy
7 Replies

3. Shell Programming and Scripting

AWK record length fix

Hi Friends, Need some help in AWK. Working on AIX 5 Have been trying the following functionality to make the record length fixed: if( length(record) < 300 ) { printf("%-300s\n", record); } In my opinion it will apply some fillers in the end. Its is not making any... (4 Replies)
Discussion started by: kanu_pathak
4 Replies

4. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies

5. Shell Programming and Scripting

Check length of record

Hi, I have a problem, please help me, I have a flat file like this: P00000000088888888999999999 0000999903 000000000000000000 P00000000077777777000000000 0000999903 000000000000000000 P00000000044444444333333333 0000999903 00000000000000000079875 P00000000066666666111111111 0000999903 ... (5 Replies)
Discussion started by: DebianJ
5 Replies

6. Shell Programming and Scripting

Make variable length record a fixed length

Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types: (H)eader Records (D)etail Records (T)railer Records The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies

7. Shell Programming and Scripting

Viewing a record of particular length

I have records with different lengths say 386, 387 and 388. Do i have any command to view all the records of the length 386 ? Please do advise. Thanks (2 Replies)
Discussion started by: bobby1015
2 Replies

8. Shell Programming and Scripting

Record length

Hi, The record length may be differ in afile. I want to display the records if the record length is not equal to 50 using sed/awk command. Thanks in Advance (6 Replies)
Discussion started by: NareshN
6 Replies

9. Shell Programming and Scripting

Convert variable length record to fixed length

Hi Team, I have an issue to split the file which is having special chracter(German Char) using awk command. I have a different length records in a file. I am separating the files based on the length using awk command. The command is working fine if the record is not having any... (7 Replies)
Discussion started by: Anthuvan
7 Replies
UNAME(1)								FSF								  UNAME(1)

NAME
uname - print system information SYNOPSIS
uname [OPTION]... DESCRIPTION
Print certain system information. With no OPTION, same as -s. -a, --all print all information, in the following order: -s, --kernel-name print the kernel name -n, --nodename print the network node hostname -r, --kernel-release print the kernel release -v, --kernel-version print the kernel version -m, --machine print the machine hardware name -p, --processor print the processor type -i, --hardware-platform print the hardware platform -o, --operating-system print the operating system --help display this help and exit --version output version information and exit AUTHOR
Written by David MacKenzie. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for uname is maintained as a Texinfo manual. If the info and uname programs are properly installed at your site, the command info uname should give you access to the complete manual. uname (coreutils) 4.5.3 February 2003 UNAME(1)
All times are GMT -4. The time now is 02:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy