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!

Scripting Assistance

Status
Not open for further replies.

beaster

Technical User
Aug 20, 2001
225
US
Hi all! This post me be sorta long, so I apologize ahead of time.

Files involved:

file#
pre_build#
master_sorted

Task 1:
Begin with the first search using file# (exam: file1) and find the text RXOTG-# (exam: RXOTG-296). It may be up to 3

numerics at the end, but no more. The text in the file# where it is located to is similiar to below:

MO CELL
RXOTG-296 B00227A
B00227B
B00227C
B00227A
B00227B
B00227C

So after finding RXOTG-#, look in the file named master_sorted and compare the number at the end of RXOTG, which in this

case is 296 to the first field in the file named master_sorted (which has fields seperated by commas.) The file

master_sorted looks similiar to below:

11,11,121,100,B00055
16,16,121,100,B00058
296,96,121,100,B00345

When it finds the match 296 from file# and master_sorted field $1, grab the number in field $3 and use it instead of 296.

Meaning it will now be RXOTG-121.

So RXOTG-121 is the text we want to keep.

Finally, we want to look for the file named pre_build# (exam: pre_build1) that matches the file# we were using, and replace

the text: TG_NUM any where in the file with the text we saved RXOTG-121.
The text in the file pre_build# is exactly like below:


RXMOI:MO=RXOTG-TG_NUM,COMB=HYB,RSITE=SITE_NUMBER,SWVER=B0531R0702;
RXESI:MO=RXOTG-TG_NUM;
RXBLE:MO=RXOTG-TG_NUM;
RXMOI:MO=RXOCF-TG_NUM,TEI=TG_TEI;
RXMOC:MO=RXOCF-TG_NUM,SIG=CONC;
RXMOI:MO=RXOIS-TG_NUM;
RXMOI:MO=RXOTF-TG_NUM,TFMODE=SA;
RXMOI:MO=RXOCON-TG_NUM,DCP=64&&87;

So we would end up with the following text inside the pre_build1 file.:

RXMOI:MO=RXOTG-121,COMB=HYB,RSITE=SITE_NUMBER,SWVER=B0531R0702;
RXESI:MO=RXOTG-121;
RXBLE:MO=RXOTG-121;
RXMOI:MO=RXOCF-121,TEI=TG_TEI;
RXMOC:MO=RXOCF-121,SIG=CONC;
RXMOI:MO=RXOIS-121;
RXMOI:MO=RXOTF-121,TFMODE=SA;
RXMOI:MO=RXOCON-121,DCP=64&&87;

The script needs to keep the files named the same in order to accomplish what I need when finalized. It also needs to keep

processing until it has finished all the file# files and written to the pre_build# files. I hope this was not too confusing!

Thanks,
Beaster
 
Beaster,
care to share what you've done so far?
I think you've done that so thing so many times - it should be eas[y|ier] to modify the previously posted solutions. vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
vlad,
It is similiar as before, but in this instance, I am looking to find some text, then compare with another file and use another number. I know it seems similiar, but it isnt.

Thanks,
beaster
 
I am just not very good at getting this info, nor putting together the script to do it.
 
beaster,
sorry for the late reply. Unfortunately I won't have enough cycles to spare to help you out in the next 3 or 4 days.
You'll have to ask others for help - I'm sure someone else will be able to give you a hand.

Sorry 'bout that - deadlines are killers!

P.S. don't forget to turn the TGML off when posting code.

vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Vlad,
CaKiwi helped me out. Thanks for your help as always too:

/^RXOTG/{
fn = FILENAME
sub(/^[^0-9]*/,&quot;&quot;,fn)
a = $1
sub(/.*-/,&quot;&quot;,a)
found = 0
while (!found && ((getline < &quot;master_sorted&quot;) > 0)) {
split ($0,b,&quot;,&quot;)
if (b[1] == a) found = 1
num = b[3]
}
close(&quot;master_sorted&quot;)
if (found) {
fn1 = &quot;pre_build&quot; fn
fn2 = &quot;pre_build_out&quot; fn
while ((getline < fn1) > 0) {
sub(/TG_NUM/,num,$0)
print > fn2
}
close(fn1)
close(fn2)
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top