row count header to the sequential file

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

reshma11
Premium Member
Premium Member
Posts: 25
Joined: Mon Oct 13, 2008 7:52 am

row count header to the sequential file

Post by reshma11 »

I need a header to a target sequential file showing how many records getting from source to target sequential file whenevery this job runs. How can I do this. Any help on this would be appreciated.
Thanks.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

If i understand you have an input sequential file and you which to basically add a header record to it which has a line count of the input header file?

If that is the case - use unix commands.
reshma11
Premium Member
Premium Member
Posts: 25
Joined: Mon Oct 13, 2008 7:52 am

Post by reshma11 »

I have a source oracle table,transformer and sequentail file. when i run this job i want to see number of records count + all records in sequentail file.

row count: 2

column1 column2
1 XXXX
2 XXX
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

Write a unix script like

var=`cat filename | wc -l`

echo "Row count : $var " > outputfile

cat file >> outputfile .

call it in after job routine .
Nag
reshma11
Premium Member
Premium Member
Posts: 25
Joined: Mon Oct 13, 2008 7:52 am

Error

Post by reshma11 »

I am getting this error

Test1..AfterJob (ExecSHSilent): Error when executing command.
*** Output from command was: ***
/**/***/***/test.ksh[2]: var: not found
cat: input/output files '/***/***/test.txt' identical
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

And if the first line is column name then $var-1
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

Try to execute your script from unix ( OS ) .If its running properly without errors then put it in after job routines .
Nag
reshma11
Premium Member
Premium Member
Posts: 25
Joined: Mon Oct 13, 2008 7:52 am

Post by reshma11 »

Getting same error in unix too. something problem with script.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

reshma11 wrote:Getting same error in unix too. something problem with script.
its running fine for me.
post the script you are using.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
reshma11
Premium Member
Premium Member
Posts: 25
Joined: Mon Oct 13, 2008 7:52 am

Post by reshma11 »

I am kind of novice in writting unix scripts, please excusme me if i am doing any worng.

#!/bin/ksh
$var
var = 'cat /***/***/test.txt | wc -l'
echo "row count : $var" > /***/**/test.txt
cat /***/***/test.txt >> /****/***/test.txt

Thanks for your help
reshma11
Premium Member
Premium Member
Posts: 25
Joined: Mon Oct 13, 2008 7:52 am

Post by reshma11 »

I am kind of novice in writting unix scripts, please excusme me if i am doing any wrong.

#!/bin/ksh
$var
var = 'cat /***/***/test.txt | wc -l'
echo "row count : $var" > /***/**/test.txt
cat /***/***/test.txt >> /****/***/test.txt

Thanks for your help
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

var = 'cat /***/***/test.txt | wc -l' is different from

var=`cat /***/***/test.txt | wc -l` --- This is correct .Observe that

Its not single quote .Its backquotes ( type tilde symbol )
Nag
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

var = 'cat /***/***/test.txt | wc -l' is different from

var=`cat /***/***/test.txt | wc -l` --- This is correct .Observe that

Its not single quote .Its backquotes ( type tilde symbol )
Nag
reshma11
Premium Member
Premium Member
Posts: 25
Joined: Mon Oct 13, 2008 7:52 am

Post by reshma11 »

I correted it to

#!/bin/ksh
var = `cat /runway/interfaces/test.txt | wc -l`
echo "row count : $var" > /runway/interfaces/test.txt
cat /runway/interfaces/test.txt >> /runway/interfaces/test.txt

run the job, but getting this error
bash-3.00$ sh test.ksh
test.ksh: var: not found
cat: input/output files '/runway/interfaces/test.txt' identical
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

var=`cat /***/***/test.txt | wc -l` ---- no space on eitherside of "="
Nag
Post Reply