views:

256

answers:

2

at the following path

\\ncsusnasent02.na.jnj.com\its_diq_na_win_dev\PowerCenter\infa_shared\WCPIT_BIO_EDW\SrcFiles\DDDMD\DDD.CLI026.WK0933.DDDMR45.001.head

I have one file DDD.CLI026.WK0933.DDDMR45.001.head

if i open this file i get data as following(in a single line)

HEADER0101IMS HEALTHDMD Weekly D DD.CLI026.WK0933.DDDMR45 Centocor DMDDRM45 [email protected]
TRAIL0101 000000000**581** 0000000000CKSUM000002236804730

we need to copy 581(it will not be same always it gets updated everyday) from this file and update it at following location

\\ncsusnasent02.na.jnj.com\its_diq_na_win_dev\PowerCenter\infa_shared\WCPIT_BIO_EDW\PrmFiles\LND\IMS_FILE_to_LND.par

when i open this file it has data as following

[WCPIT_BIO_EDW.WF:w_DDDMD_LNDG_IMS_NONRET_SALES]
$$Cust_RowCount=72648
$$Sales_RowCount=5235998
$$OuletChangeLog_RowCount=931
**$$DRM45_RowCount=581**
$$Control_RowCount=4495
$$Outl_Subcat_RowCount=105
$$Fac_Subcat_RowCount=149

we need to update 581 against $$DRM45_RowCount

A: 

Probably you can solve this using Windows scripting (I'm not expert in that), but usually I rather install CygWin and wrote a bash/awk/sed script for such operations. Is this acceptable for you and your situation?

igustin
no,i need to add this script in a etl tool named informatica at session level............
Irveen
Hm, I don't know about this etl tool, but if you can run batch/command, you also can run shell script via cygwin for sure. This processing is kind of trivial for Linux shell's text utilities.
igustin
+1  A: 

Assuming that header is all on a single line (and the "**" are added by you just to emphasize what you want extracted), you can extract the number with:

export num=$(expr 0 + $(cat infile | cut -c137-148))

This extracts the number (assuming your file is specified correctly). The expression "0 + n" will strip off leading zeros. Then, using my code from your other question:

cat parfile | awk -va=${num} '{
    if (substr($0,1,17) == "$$DRM45_RowCount=") {
        print "$$DRM45_RowCount=" a
    } else {
        print
    }
}' > newparfile

Now newparfile should contain the value you want.

paxdiablo
we are now shifting from unix platform to windows ...can u plz help us in implementing it in windows......
Irveen
You need Cygwin or MinGW - then you get all the UNIX utilities you need and they're far better than the standard Windows commond interpreter.
paxdiablo
well it is out of scope...........only thing i can do so to convert the commands fro unix to cmd
Irveen