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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Validation help!

Status
Not open for further replies.

gophertee

Programmer
Oct 11, 2000
27
US
I have an issue which I been trying to solve.
In this program I am basically looking at files and making sure they look alike. If there is any difference from the file to the record it will get tossed in a hold directory (i.e File=TOVVRIDE1234, record=TOVRRIDE1235). Because of this difference it gets tossed.
My dilemma is this; I will get a file called TOVVRIDE1234.1 and the records within are TOVRRIDE1234 Now because the file says .1 at the end it is sending it to the hold directory. I want to accept files with a .1, .2, etc.. What's happening is that the program looks at the record and will see the TOVVRIDE1234, than look at the file and see TOVRRIDE1234.1 which says "Hey lets toss this one" ANy idea on how to accept files with a .1, .2, etc?

#! /usr/bin/awk
##############################################################################
# This program will verify the store number in 'office' which
# matches the store number in the file. Beginning at character
# #3 - 8 it will verify store numbers are the same. Store number
# with four characters will be padded with a zero which also gets
# trapped. In any case, if there is a corrput record or file, it
# goes into a hold directory with a timestamp associated.
#
###############################################################################

BEGIN {
if (substr(ARGV[1],0,3) != "TOV") {
office = substr(ARGV[1],7);
}
else {
office = substr(ARGV[1],9);
}
}
{
sys_call = "mv " ARGV[1] " /rec/timework/timehold/" ARGV[1] ".`date '+%j%H%M%S'`";
# sys_call = "mv " FILENAME " /usr/acct/acmmgr/hold/" FILENAME ".`date '+%j%H%M%S'`";

############################################################################
# This is where we read the character(s) checking to see if there is a
# zero and if it is a mirror image of the office validaion. If not,
# than sys_call is set to move the record into the hold directory.
############################################################################

if (substr($0,3,1) == "0") {
if (substr($0,4,4) != office) {
system(sys_call);
exit(0);
}
}
else {
if (substr($0,3,5) != office) {
system(sys_call);
exit(0);
}
}
if (substr($0,3,5) != office) {
system(sys_call);
}
}
 
Hi gophertee,

Ignore the .1 or .2 like this:


BEGIN {
if (substr(ARGV[1],0,3) != "TOV") {
office = substr(ARGV[1],7,4); # added ,4
}
else {
office = substr(ARGV[1],9,4); # added ,4

}

rest of script is O.K.

Hope this helps.


flogrr
flogr@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top