Page 1 of 2

row count header to the sequential file

Posted: Thu May 21, 2009 9:48 am
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.

Posted: Thu May 21, 2009 9:53 am
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.

Posted: Thu May 21, 2009 10:43 am
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

Posted: Thu May 21, 2009 11:13 am
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 .

Error

Posted: Thu May 21, 2009 12:40 pm
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

Posted: Thu May 21, 2009 12:41 pm
by priyadarshikunal
And if the first line is column name then $var-1

Posted: Thu May 21, 2009 12:42 pm
by nagarjuna
Try to execute your script from unix ( OS ) .If its running properly without errors then put it in after job routines .

Posted: Thu May 21, 2009 12:53 pm
by reshma11
Getting same error in unix too. something problem with script.

Posted: Thu May 21, 2009 12:59 pm
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.

Posted: Thu May 21, 2009 1:32 pm
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

Posted: Thu May 21, 2009 1:34 pm
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

Posted: Thu May 21, 2009 1:38 pm
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 )

Posted: Thu May 21, 2009 1:38 pm
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 )

Posted: Thu May 21, 2009 1:49 pm
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

Posted: Thu May 21, 2009 9:01 pm
by nagarjuna
var=`cat /***/***/test.txt | wc -l` ---- no space on eitherside of "="