LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-05-2013, 05:11 AM   #31
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389

Strange.

Please do the following and post the output:

Copy/paste the following to a file (foo.sh)
Code:
#!/bin/ksh

typeset -A arrayName

arrayName[CID]="Just testing"

echo ${arrayName[CID]}
Make it executable:
Code:
chmod 750 foo.sh
Run the script:
Code:
./foo.sh
Output generated should be:
Code:
$ ./foo.sh 
Just testing
 
Old 12-05-2013, 05:26 AM   #32
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
getting same.....
$ sh foo.sh
foo.sh: line 3: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
Just testing
======================

but when i tried with this:

$ ./foo.sh
Just testing
no error.....why so?

Last edited by santosh0782; 12-05-2013 at 05:28 AM.
 
Old 12-05-2013, 05:37 AM   #33
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Quote:
Originally Posted by santosh0782 View Post
getting same.....
$ sh foo.sh
foo.sh: line 3: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
Just testing
======================

but when i tried with this:

$ ./foo.sh
Just testing
no error.....why so?
If you use sh sriptname.sh then sh is used and _not_ the shell in the first line of the script. sh is a link to bash (on most systems).

To run a script you use scriptname.sh (assuming the script can be found in the PATH setting) or ./scriptname.sh (assuming you stand in the directory the script is in).
You could also use /full/path/to/criptname.sh
 
1 members found this post helpful.
Old 12-05-2013, 09:50 PM   #34
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
ok.. Thanks a ton :-)

now i'll try to prepare a script with the time window, as advised by you in the post#25. will let you know the status.

i'll post here if any query arises..
 
Old 12-07-2013, 03:50 AM   #35
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
some other person is working on that project now.
anyway, i'll be in touch with you, as i wanted to be like you in the scripting world.
meanwhile i am going through your linux related collection in your blogs...
will post you the queries here... Thanks a lot once again... :-)

Last edited by santosh0782; 12-07-2013 at 03:52 AM.
 
Old 12-07-2013, 04:23 AM   #36
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Quote:
Originally Posted by santosh0782 View Post
some other person is working on that project now.
That is too bad. But looking at your level of scripting knowledge and the complexity of the work that needs to be done this probably isn't totally unexpected.

On the up side: You learned some valuable things while working on this project.

Quote:
meanwhile i am going through your linux related collection in your blogs...
The Bash section of my blog has some valuable info. Also have a look at the Linux Shell Scripting Tutorial link in the Shell section.

The only way to learn scripting is practise. Start with simple things, have a look at other scripts and try to understand how things are done.

Quote:
Thanks a lot once again... :-)
You're welcome.

Last edited by druuna; 12-07-2013 at 08:32 AM. Reason: Fixed a weird sentence
 
Old 12-07-2013, 10:09 PM   #37
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
ok.. sure, i'll start reading Linux Shell Scripting Tutorial in the shell section of your blogs.

Thanks a lot :-)
 
Old 12-13-2013, 01:20 AM   #38
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Hi,

is there any simpler way to write below:

if [[ "$AS2declinedper" -gt 15 || "$SnSdeclinedper" -gt 10 || "$Colldeclinedper" -gt 15 || "$CCCDdeclinedper" -gt 20 || "$SUMdeclinedper" -gt 15 ]]
then
echo "RED"
elif [[ "$AS2declinedper" -gt 10 && "$AS2declinedper" -le 15 || "$SnSdeclinedper" -gt 5 && "$SnSdeclinedper" -le 10 || "$Colldeclinedper" -gt 10 && "$Colldeclinedper" -le 15 || "$CCCDdeclinedper" -gt 15 && "$CCCDdeclinedper" -le 20|| "$SUMdeclinedper" -gt 10 && "$SUMdeclinedper" -le 15 ]]
the
echo "AMBER"
else
echo "GREEN"
fi
 
Old 12-13-2013, 03:03 AM   #39
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
The specific part you show performs needed test and I don't see a way too make it simpler.

You can make it more (human) readable:
Code:
if [[   "$AS2declinedper"  -gt 15 || \
        "$SnSdeclinedper"  -gt 10 || \
        "$Colldeclinedper" -gt 15 || \
        "$CCCDdeclinedper" -gt 20 || \
        "$SUMdeclinedper"  -gt 15 ]]
then
  echo "RED"
elif [[ "$AS2declinedper"  -gt 10 && "$AS2declinedper"  -le 15 || \
        "$SnSdeclinedper"  -gt  5 && "$SnSdeclinedper"  -le 10 || \
        "$Colldeclinedper" -gt 10 && "$Colldeclinedper" -le 15 || \
        "$CCCDdeclinedper" -gt 15 && "$CCCDdeclinedper" -le 20 || \
        "$SUMdeclinedper"  -gt 10 && "$SUMdeclinedper"  -le 15 ]]
then
  echo "AMBER"
else
  echo "GREEN"
fi
 
1 members found this post helpful.
Old 12-13-2013, 04:12 AM   #40
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Thanks a lot for making it more human readable. :-)

as of now,i have just written the code, once i'll get the data file then i'll try running this script, will let you know the status.

Thanks again :-)
 
Old 12-19-2013, 12:30 AM   #41
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Hi,

I have a script which takes data for every 1 hour, if i want to make the same script to take data for every 30 minutes then where should i make the changes..could you please advise?

present script:
Code:
#!/bin/ksh

cd /home/www/BCARD/data/dcp

rm -rf ./pay_dt.txt ./pay_dt1.txt ./DCP-hourly* ./CCCD-hourly* ./KIVR-hourly* ./AS_hourly_pay1*

user=biscsi
dt=`date '+%d%m%y'`

tody=`ksh today`

scp $user@picard.barclaycard.co.uk:/u/epayadm/log/audit.log ./
scp $user@picard.barclaycard.co.uk:/u/epayadm/log/audit$tody.log ./

cat ./audit.log ./audit$tody.log > ./audit1.tmp
sed 's/^/20/g' ./audit1.tmp > ./audit.tmp

for i in `cat ./channel | awk '{print $1}'`
do
fname=`egrep $i ./channel | awk '{print $2}'`
awk -F',' '{print substr($1,0,10),$14,$10,$11}' ./audit.tmp | awk '($2=='000')' | egrep "$i" | awk '{print $1}' | sort | uniq -c > ./$fname-hourly-pay1a.txt
awk -F',' '{print substr($1,0,10),$14,$10,$11}' ./audit.tmp | awk '($2!='000')' | egrep "$i" | awk '{print $1}' | sort | uniq -c > ./$fname-hourly-pay1d.txt
done

#Convert to epcoh

set -- $(date -u '+%Y %j %H %M %S');DAYS=$(( 365*($1 - 1970) + ($1 - 1969)/4 + $2 - 1 ));UT=$(( $5 + 60*($4 + 60*($3 + 24*$DAYS)) ))

#last 24 hours
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
./convert_dt.pl $UT >> ./pay_dt.txt
./convert_dt1.pl $UT >> ./pay_dt1.txt
UT=`expr $UT - 3600`
done

for i in `cat ./channel | awk '{print $1}'`
do
for j in `cat pay_dt1.txt`
do
fname=`egrep "$i" ./channel | awk '{print $2}'`
val=`awk -F',' '{print substr($1,0,10),$10,$11}' ./audit.tmp | egrep "$i" | grep $j | awk '{k+=$2}END{printf "%-10d\n",k/100}' | awk '{print $1}'`
echo $j $val >> ./$fname-hourly-payv.txt
done
done

for i in `cat ./channel | awk '{print $1}'`
do
for j in `cat pay_dt1.txt`
do
fname=`egrep "$i" ./channel | awk '{print $2}'`
vala=`grep "$j" ./$fname-hourly-pay1a.txt`
vald=`grep "$j" ./$fname-hourly-pay1d.txt`

if [[ ! -n $vala ]]
then
echo "0 $j" >> ./$fname-hourly-paya.txt
else
echo $vala >> ./$fname-hourly-paya.txt
fi

if [[ ! -n $vald ]]
then
echo "0 $j" >> ./$fname-hourly-payd.txt
else
echo $vald >> ./$fname-hourly-payd.txt
fi
done
done
(cat ./pay_dt.txt) | while read LINE
do
vala=`grep "$LINE" ./AS_hourly_paya.txt | awk -F'|' '{printf "%-10d\n",$2}'`
vald=`grep "$LINE" ./AS_hourly_payd.txt | awk -F'|' '{printf "%-10d\n",$2}'`
valv=`grep "$LINE" ./AS_hourly_payv.txt | awk -F'|' '{printf "%-10d\n",$2}'`
vals=`grep "$LINE" ./AS_hourly_pays.txt | awk -F'|' '{printf "%-10d\n",$2}'`

if [[ ! -n $vala ]]
then
echo $LINE 0 >> ./AS_hourly_pay1a.txt
else
echo $LINE $vala >> ./AS_hourly_pay1a.txt
fi

if [[ ! -n $vald ]]
then
echo $LINE 0 >> ./AS_hourly_pay1d.txt
else
echo $LINE $vald >> ./AS_hourly_pay1d.txt
fi

if [[ ! -n $valv ]]
then
echo $LINE 0 >> ./AS_hourly_pay1v.txt
else
echo $LINE $valv >> ./AS_hourly_pay1v.txt
fi

if [[ ! -n $vals ]]
then
echo $LINE 0 >> ./AS_hourly_pay1s.txt
else
echo $LINE $vals >> ./AS_hourly_pay1s.txt
fi

done
#Online

echo "<chart palette='1' caption='Online Payment Authorizations &lt;Last 24 Hours&gt;' baseFontSize ='12' showValues='0' showLegend='1' showlabel='0' bgColor='999999,FFFFFF' bgAlpha='50' showlabels='1' chartTopMargin='0' chartbottomMargin='5' pyaxisname='COUNT' syaxisname='VALUE' sNumberPrefix='%A3' numdivlines='0' formatNumberScale='1' sformatNumberScale='1' xaxisname='HOUR'>" > ./dcp_onl_hr.xml
echo "<categories>" >> ./dcp_onl_hr.xml
for i in `sort ./AS_hourly_pay1v.txt | tail -24 | awk '{print $2}'`
do
echo "<category label='$i' />" >> ./dcp_onl_hr.xml
done
echo "</categories>" >> ./dcp_onl_hr.xml
echo "<dataset seriesName='Approved' color='7F38EC'>" >> ./dcp_onl_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
vala=`sort ./AS_hourly_pay1a.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$3}' | awk '{print $1}'`
echo "<set value='$vala' />" >> ./dcp_onl_hr.xml
done
echo "</dataset>" >> ./dcp_onl_hr.xml
echo "<dataset seriesName='Declined' color='810541'>" >> ./dcp_onl_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
vald=`sort ./AS_hourly_pay1d.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$3}' | awk '{print $1}'`
vals=`sort ./AS_hourly_pay1s.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$3}' | awk '{print $1}'`
valt=`expr $vald + $vals`
echo "<set value='$valt' />" >> ./dcp_onl_hr.xml
done
echo "</dataset>" >> ./dcp_onl_hr.xml
echo "<dataset seriesName='Value' color='00FF00' parentYAxis='S' renderAs='Line'>" >> ./dcp_onl_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
vals=`sort ./AS_hourly_pay1v.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$3}' | awk '{print $1}'`
echo "<set value='$vals' />" >> ./dcp_onl_hr.xml
done
echo "</dataset>" >> ./dcp_onl_hr.xml
echo "<styles>" >> ./dcp_onl_hr.xml
echo "                <definition>" >> ./dcp_onl_hr.xml
echo "                        <style name='myCaptionFont' type='font' size='14' bold='1' underline='1' />" >> ./dcp_onl_hr.xml
echo "                        <style name='myAxisFont' type='font' size='12' bold='1' underline='0' />" >> ./dcp_onl_hr.xml
echo "                        <style name='myFont' type='font' size='11' bold='1' underline='0' />" >> ./dcp_onl_hr.xml
echo "                        <style name='myBevel' type='Bevel'/>" >> ./dcp_onl_hr.xml
echo "                </definition>" >> ./dcp_onl_hr.xml
echo "                <application>" >> ./dcp_onl_hr.xml
echo "                        <apply toObject='Caption' styles='myCaptionFont' />" >> ./dcp_onl_hr.xml
echo "                        <apply toObject='xaxisname' styles='myAxisFont' />" >> ./dcp_onl_hr.xml
echo "                        <apply toObject='yaxisname' styles='myAxisFont' />" >> ./dcp_onl_hr.xml
echo "                        <apply toObject='subcaption' styles='myCaptionFont' />" >> ./dcp_onl_hr.xml
echo "                        <apply toObject='datalabels' styles='myFont' />" >> ./dcp_onl_hr.xml
echo "                        <apply toObject='legend' styles='myFont' />" >> ./dcp_onl_hr.xml
echo "                        <apply toObject='Background' styles='myBevel'  />" >> ./dcp_onl_hr.xml
echo "                        <apply toObject='canvas' styles='myBevel'  />" >> ./dcp_onl_hr.xml
echo "                </application>" >> ./dcp_onl_hr.xml
echo "        </styles>" >> ./dcp_onl_hr.xml
echo "</chart>" >> ./dcp_onl_hr.xml

#Summary

echo "<chart palette='1' caption='Payment Authorizations &lt;Last 24 Hours&gt;' baseFontSize ='12' showValues='0' showLegend='1' showlabel='0' bgColor='999999,FFFFFF' bgAlpha='50' showlabels='1' chartTopMargin='0' chartbottomMargin='5' pyaxisname='COUNT' syaxisname='VALUE' sNumberPrefix='%A3' numdivlines='0' formatNumberScale='1' sformatNumberScale='1' xaxisname='HOUR'>" > ./dcp_sum_hr.xml
echo "<categories>" >> ./dcp_sum_hr.xml
for i in `sort ./AS_hourly_pay1v.txt | tail -24 | awk '{print $2}'`
do
echo "<category label='$i' />" >> ./dcp_sum_hr.xml
done
echo "</categories>" >> ./dcp_sum_hr.xml
echo "<dataset seriesName='Approved' color='7F38EC'>" >> ./dcp_sum_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
vala=`sort ./AS_hourly_pay1a.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$3}' | awk '{print $1}'`
valad=`sort -k2 ./DCP-hourly-paya.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
valac=`sort -k2 ./CCCD-hourly-paya.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
valak=`sort -k2 ./KIVR-hourly-paya.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
valf=`expr $vala + $valad + $valac + $valak`
echo "<set value='$valf' />" >> ./dcp_sum_hr.xml
done
echo "</dataset>" >> ./dcp_sum_hr.xml
echo "<dataset seriesName='Declined' color='810541'>" >> ./dcp_sum_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
vald=`sort ./AS_hourly_pay1d.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$3}' | awk '{print $1}'`
vals=`sort ./AS_hourly_pay1s.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$3}' | awk '{print $1}'`
valad=`sort -k2 ./DCP-hourly-payd.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
valac=`sort -k2 ./CCCD-hourly-payd.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
valak=`sort -k2 ./KIVR-hourly-payd.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
valf=`expr $vals + $vald + $valad + $valac + $valak`
echo "<set value='$valf' />" >> ./dcp_sum_hr.xml
done
echo "</dataset>" >> ./dcp_sum_hr.xml
echo "<dataset seriesName='Value' color='00FF00' parentYAxis='S' renderAs='Line'>" >> ./dcp_sum_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
vals=`sort ./AS_hourly_pay1v.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$3}' | awk '{print $1}'`
vald=`sort ./DCP-hourly-payv.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$2}' | awk '{print $1}'`
valc=`sort ./CCCD-hourly-payv.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$2}' | awk '{print $1}'`
valk=`sort ./KIVR-hourly-payv.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$2}' | awk '{print $1}'`
valf=`expr $vals + $vald + $valc + $valk`
echo "<set value='$valf' />" >> ./dcp_sum_hr.xml
done
echo "</dataset>" >> ./dcp_sum_hr.xml
echo "<styles>" >> ./dcp_sum_hr.xml
echo "                <definition>" >> ./dcp_sum_hr.xml
echo "                        <style name='myCaptionFont' type='font' size='14' bold='1' underline='1' />" >> ./dcp_sum_hr.xml
echo "                        <style name='myAxisFont' type='font' size='12' bold='1' underline='0' />" >> ./dcp_sum_hr.xml
echo "                        <style name='myFont' type='font' size='11' bold='1' underline='0' />" >> ./dcp_sum_hr.xml
echo "                        <style name='myBevel' type='Bevel'/>" >> ./dcp_sum_hr.xml
echo "                </definition>" >> ./dcp_sum_hr.xml
echo "                <application>" >> ./dcp_sum_hr.xml
echo "                        <apply toObject='Caption' styles='myCaptionFont' />" >> ./dcp_sum_hr.xml
echo "                        <apply toObject='xaxisname' styles='myAxisFont' />" >> ./dcp_sum_hr.xml
echo "                        <apply toObject='yaxisname' styles='myAxisFont' />" >> ./dcp_sum_hr.xml
echo "                        <apply toObject='subcaption' styles='myCaptionFont' />" >> ./dcp_sum_hr.xml
echo "                        <apply toObject='datalabels' styles='myFont' />" >> ./dcp_sum_hr.xml
echo "                        <apply toObject='legend' styles='myFont' />" >> ./dcp_sum_hr.xml
echo "                        <apply toObject='Background' styles='myBevel'  />" >> ./dcp_sum_hr.xml
echo "                        <apply toObject='canvas' styles='myBevel'  />" >> ./dcp_sum_hr.xml
echo "                </application>" >> ./dcp_sum_hr.xml
echo "        </styles>" >> ./dcp_sum_hr.xml
echo "</chart>" >> ./dcp_sum_hr.xml

#DCP
echo "<chart palette='1' caption='S&S Payment Authorizations &lt;Last 24 Hours&gt;' baseFontSize ='12' showValues='0' showLegend='1' showlabel='0' bgColor='999999,FFFFFF' bgAlpha='50' showlabels='1' chartTopMargin='0' chartbottomMargin='5' pyaxisname='COUNT' syaxisname='VALUE' sNumberPrefix='%A3' numdivlines='0' formatNumberScale='1' sformatNumberScale='1' xaxisname='HOUR'>" > ./dcp_sales_hr.xml
echo "<categories>" >> ./dcp_sales_hr.xml
for i in `sort ./DCP-hourly-payv.txt | tail -24 | awk '{print substr($1,9,2)}'`
do
echo "<category label='$i' />" >> ./dcp_sales_hr.xml
done
echo "</categories>" >> ./dcp_sales_hr.xml
echo "<dataset seriesName='Approved' color='7F38EC'>" >> ./dcp_sales_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
valad=`sort -k2 ./DCP-hourly-paya.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
echo "<set value='$valad' />" >> ./dcp_sales_hr.xml
done
echo "</dataset>" >> ./dcp_sales_hr.xml
echo "<dataset seriesName='Declined' color='810541'>" >> ./dcp_sales_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
valad=`sort -k2 ./DCP-hourly-payd.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
echo "<set value='$valad' />" >> ./dcp_sales_hr.xml
done
echo "</dataset>" >> ./dcp_sales_hr.xml
echo "<dataset seriesName='Value' color='00FF00' parentYAxis='S' renderAs='Line'>" >> ./dcp_sales_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
vald=`sort ./DCP-hourly-payv.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$2}' | awk '{print $1}'`
echo "<set value='$vald' />" >> ./dcp_sales_hr.xml
done
echo "</dataset>" >> ./dcp_sales_hr.xml
echo "<styles>" >> ./dcp_sales_hr.xml
echo "                <definition>" >> ./dcp_sales_hr.xml
echo "                        <style name='myCaptionFont' type='font' size='14' bold='1' underline='1' />" >> ./dcp_sales_hr.xml
echo "                        <style name='myAxisFont' type='font' size='12' bold='1' underline='0' />" >> ./dcp_sales_hr.xml
echo "                        <style name='myFont' type='font' size='11' bold='1' underline='0' />" >> ./dcp_sales_hr.xml
echo "                        <style name='myBevel' type='Bevel'/>" >> ./dcp_sales_hr.xml
echo "                </definition>" >> ./dcp_sales_hr.xml
echo "                <application>" >> ./dcp_sales_hr.xml
echo "                        <apply toObject='Caption' styles='myCaptionFont' />" >> ./dcp_sales_hr.xml
echo "                        <apply toObject='xaxisname' styles='myAxisFont' />" >> ./dcp_sales_hr.xml
echo "                        <apply toObject='yaxisname' styles='myAxisFont' />" >> ./dcp_sales_hr.xml
echo "                        <apply toObject='subcaption' styles='myCaptionFont' />" >> ./dcp_sales_hr.xml
echo "                        <apply toObject='datalabels' styles='myFont' />" >> ./dcp_sales_hr.xml
echo "                        <apply toObject='legend' styles='myFont' />" >> ./dcp_sales_hr.xml
echo "                        <apply toObject='Background' styles='myBevel'  />" >> ./dcp_sales_hr.xml
echo "                        <apply toObject='canvas' styles='myBevel'  />" >> ./dcp_sales_hr.xml
echo "                </application>" >> ./dcp_sales_hr.xml
echo "        </styles>" >> ./dcp_sales_hr.xml
echo "</chart>" >> ./dcp_sales_hr.xml

#CCCD

echo "<chart palette='1' caption='Agent Desktop - Payment Authorizations &lt;Last 24 Hours&gt;' baseFontSize ='12' showValues='0' showLegend='1' showlabel='0' bgColor='999999,FFFFFF' bgAlpha='50' showlabels='1' chartTopMargin='0' chartbottomMargin='5' pyaxisname='COUNT' syaxisname='VALUE' sNumberPrefix='%A3' numdivlines='0' formatNumberScale='1' sformatNumberScale='1' xaxisname='HOUR'>" > ./dcp_ccd_hr.xml
echo "<categories>" >> ./dcp_ccd_hr.xml
for i in `sort ./CCCD-hourly-payv.txt | tail -24 | awk '{print substr($1,9,2)}'`
do
echo "<category label='$i' />" >> ./dcp_ccd_hr.xml
done
echo "</categories>" >> ./dcp_ccd_hr.xml
echo "<dataset seriesName='Approved' color='7F38EC'>" >> ./dcp_ccd_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
valad=`sort -k2 ./CCCD-hourly-paya.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
echo "<set value='$valad' />" >> ./dcp_ccd_hr.xml
done
echo "</dataset>" >> ./dcp_ccd_hr.xml
echo "<dataset seriesName='Declined' color='810541'>" >> ./dcp_ccd_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
valad=`sort -k2 ./CCCD-hourly-payd.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$1}' | awk '{print $1}'`
echo "<set value='$valad' />" >> ./dcp_ccd_hr.xml
done
echo "</dataset>" >> ./dcp_ccd_hr.xml
echo "<dataset seriesName='Value' color='00FF00' parentYAxis='S' renderAs='Line'>" >> ./dcp_ccd_hr.xml
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
vald=`sort ./CCCD-hourly-payv.txt | head -$j | tail -1 | awk '{printf "%-10d\n",$2}' | awk '{print $1}'`
echo "<set value='$vald' />" >> ./dcp_ccd_hr.xml
done
echo "</dataset>" >> ./dcp_ccd_hr.xml
echo "<styles>" >> ./dcp_ccd_hr.xml
echo "                <definition>" >> ./dcp_ccd_hr.xml
echo "                        <style name='myCaptionFont' type='font' size='14' bold='1' underline='1' />" >> ./dcp_ccd_hr.xml
echo "                        <style name='myAxisFont' type='font' size='12' bold='1' underline='0' />" >> ./dcp_ccd_hr.xml
echo "                        <style name='myFont' type='font' size='11' bold='1' underline='0' />" >> ./dcp_ccd_hr.xml
echo "                        <style name='myBevel' type='Bevel'/>" >> ./dcp_ccd_hr.xml
echo "                </definition>" >> ./dcp_ccd_hr.xml
echo "                <application>" >> ./dcp_ccd_hr.xml
echo "                        <apply toObject='Caption' styles='myCaptionFont' />" >> ./dcp_ccd_hr.xml
echo "                        <apply toObject='xaxisname' styles='myAxisFont' />" >> ./dcp_ccd_hr.xml
echo "                        <apply toObject='yaxisname' styles='myAxisFont' />" >> ./dcp_ccd_hr.xml
echo "                        <apply toObject='subcaption' styles='myCaptionFont' />" >> ./dcp_ccd_hr.xml
echo "                        <apply toObject='datalabels' styles='myFont' />" >> ./dcp_ccd_hr.xml
echo "                        <apply toObject='legend' styles='myFont' />" >> ./dcp_ccd_hr.xml
echo "                        <apply toObject='Background' styles='myBevel'  />" >> ./dcp_ccd_hr.xml
echo "                        <apply toObject='canvas' styles='myBevel'  />" >> ./dcp_ccd_hr.xml
echo "                </application>" >> ./dcp_ccd_hr.xml
echo "        </styles>" >> ./dcp_ccd_hr.xml
echo "</chart>" >> ./dcp_ccd_hr.xml
=================================
data files used above contains the data as:
1. data in channel file(for AS2,DCP,KIVR and CCCD):
2893907 DCP
4451746 CCCD
4592242|4592267|4592275 KIVR

2. data in audit.tmp file(first column is the date with HHMMSS):

20131218000124,131218000127,100,992261,476248******8322,,,1608,809087,3505,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000133,131218000137,200,992612,475714******5463,,,1604,MERCHANT-DECLINE,50000,4451746,826,826,106,8,00,CV2200,8,2,4,4,1,1,1,1
20131218000322,131218000325,100,992574,475117******1080,,,1410,223569,16462,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000326,131218000329,100,992642,675922******8589,,0812,1507,518000,44926,2893907,826,826,000, 8,00,CV2100,8,2,2,2,1,1,1,1
20131218000403,131218000406,100,992613,465911******2007,,,1608,040485,17495,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000420,131218000423,100,992520,454313******3120,,,1804,316085,5000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000554,131218000558,100,992575,446291******7818,,,1607,018936,2500,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000643,131218000646,100,992614,557351******3868,,,1405,615000,10000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000654,131218000656,100,992521,456726******4299,,,1605,015620,25000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000657,131218000700,100,992576,453978******6367,,,1502,065904,20000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000657,131218000700,100,992643,475130******3652,,,1511,451675,50000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000658,131218000701,100,992615,475130******3272,,,1604,823951,7000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000812,131218000814,200,992577,475714******5463,,,1605,DECLINE,50000,4451746,826,826,002,4,0 0,CV2200,8,1,1,1,,,,
20131218000921,131218000924,200,992644,475714******5463,,,1604,163530,50000,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218000938,131218000940,100,992616,446238******5817,,,1509,DECLINE,12000,2893907,826,826,002,4,0 0,CV2100,8,4,1,1,,,,
20131218000950,131218000953,100,992645,492181******4879,,,1510,018238,8700,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001045,131218001049,100,992578,446271******5013,,,1511,018676,5000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001117,131218001120,100,992617,465861******1108,,,1609,011940,2500,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001132,131218001135,200,992646,492181******4626,,,1402,018110,75299,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218001136,131218001139,100,992618,475128******9422,,,1312,138256,7000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001205,131218001208,200,992619,465935******9305,,,1605,035936,35000,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218001212,131218001215,100,992647,475130******9247,,,1503,547678,20000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218001245,131218001248,100,992579,475129******1112,,,1610,737787,7127,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001421,131218001423,100,992772,456726******0367,,,1511,DECLINE,4931,2893907,826,826,002,4,00 ,CV2100,8,1,1,1,,,,
20131218001423,131218001426,100,992580,557349******9016,,,1406,494600,11000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218001428,131218001431,100,992648,465902******3079,,,1607,043034,2200,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001507,131218001510,100,992620,453978******8618,,,1502,050914,60000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218001829,131218001832,100,992621,475130******6976,,,1506,669353,290810,2893907,826,826,000,8,0 0,CV2100,8,2,2,2,1,1,1,1
20131218001841,131218001844,100,992773,475130******2744,,,1511,169092,2496,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001944,131218001947,100,992649,446277******0158,,,1405,785750,120000,2893907,826,826,000,8,0 0,CV2100,8,2,2,2,1,1,1,1
20131218001946,131218001949,100,992822,456726******4767,,,1512,787730,5000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218002305,131218002308,200,992650,446238******5817,,,1509,018086,12000,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
==============

now with this data file the above script is taking the data during that particular hour and accumulating it and now the requirement is to add the data after every 30 minutes.(above, i have given the half part of the script, because if it works for them then will implement the same to others)

Last edited by santosh0782; 12-19-2013 at 03:00 AM.
 
Old 12-19-2013, 02:44 AM   #42
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
@santosh0782: There are too many unknowns to be able to help you with this.

A few examples:
- What do the audit.log files look like,
- Where does channel come from and what's the content,
- What does convert_dt.pl do,
- What is the content of pay_dt.txt and pay_dt1.txt.

Some code doesn't seem to make sense. A few examples:
- Is this correct: tody=`ksh today`,
- Why is the loop present, i is never used inside the loop:
Code:
#last 24 hours
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
  ./convert_dt.pl $UT >> ./pay_dt.txt
  ./convert_dt1.pl $UT >> ./pay_dt1.txt
  UT=`expr $UT - 3600`
done
A lot of the code can be written more efficient, but that might be considered an aesthetic issue (although it would make the code faster and easier to read).

In general: The whole script is build with a 1 hour time frame in mind which makes changing it into a 30 minute driven script rather hard (if not impossible). I would suggest having a good look at the data you have to start with (which seems to be the audit logs) and start fresh from there.
 
Old 12-19-2013, 03:25 AM   #43
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Hi,

Here are the answers for the questions you asked:
1. What do the audit.log files look like,
ANS--> audit.log its data going in audit.tmp(have sent the sample of audit.tmp(first column is the date with HHMMSS))
audit.tmp:
20131218000124,131218000127,100,992261,476248******8322,,,1608,809087,3505,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000133,131218000137,200,992612,475714******5463,,,1604,MERCHANT-DECLINE,50000,4451746,826,826,106,8,00,CV2200,8,2,4,4,1,1,1,1
20131218000322,131218000325,100,992574,475117******1080,,,1410,223569,16462,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000326,131218000329,100,992642,675922******8589,,0812,1507,518000,44926,2893907,826,826,000, 8,00,CV2100,8,2,2,2,1,1,1,1
20131218000403,131218000406,100,992613,465911******2007,,,1608,040485,17495,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000420,131218000423,100,992520,454313******3120,,,1804,316085,5000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000554,131218000558,100,992575,446291******7818,,,1607,018936,2500,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000643,131218000646,100,992614,557351******3868,,,1405,615000,10000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000654,131218000656,100,992521,456726******4299,,,1605,015620,25000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000657,131218000700,100,992576,453978******6367,,,1502,065904,20000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000657,131218000700,100,992643,475130******3652,,,1511,451675,50000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000658,131218000701,100,992615,475130******3272,,,1604,823951,7000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000812,131218000814,200,992577,475714******5463,,,1605,DECLINE,50000,4451746,826,826,002,4,0 0,CV2200,8,1,1,1,,,,
20131218000921,131218000924,200,992644,475714******5463,,,1604,163530,50000,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218000938,131218000940,100,992616,446238******5817,,,1509,DECLINE,12000,2893907,826,826,002,4,0 0,CV2100,8,4,1,1,,,,
20131218000950,131218000953,100,992645,492181******4879,,,1510,018238,8700,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001045,131218001049,100,992578,446271******5013,,,1511,018676,5000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001117,131218001120,100,992617,465861******1108,,,1609,011940,2500,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001132,131218001135,200,992646,492181******4626,,,1402,018110,75299,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218001136,131218001139,100,992618,475128******9422,,,1312,138256,7000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001205,131218001208,200,992619,465935******9305,,,1605,035936,35000,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218001212,131218001215,100,992647,475130******9247,,,1503,547678,20000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218001245,131218001248,100,992579,475129******1112,,,1610,737787,7127,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001421,131218001423,100,992772,456726******0367,,,1511,DECLINE,4931,2893907,826,826,002,4,00 ,CV2100,8,1,1,1,,,,
20131218001423,131218001426,100,992580,557349******9016,,,1406,494600,11000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218001428,131218001431,100,992648,465902******3079,,,1607,043034,2200,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001507,131218001510,100,992620,453978******8618,,,1502,050914,60000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218001829,131218001832,100,992621,475130******6976,,,1506,669353,290810,2893907,826,826,000,8,0 0,CV2100,8,2,2,2,1,1,1,1
20131218001841,131218001844,100,992773,475130******2744,,,1511,169092,2496,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001944,131218001947,100,992649,446277******0158,,,1405,785750,120000,2893907,826,826,000,8,0 0,CV2100,8,2,2,2,1,1,1,1
20131218001946,131218001949,100,992822,456726******4767,,,1512,787730,5000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218002305,131218002308,200,992650,446238******5817,,,1509,018086,12000,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218002317,131218002320,100,992823,475117******8466,,,1504,288632,16000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218002333,131218002336,100,992774,465901******3046,,,1606,033514,43707,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218002527,131218002529,200,992775,475127******6564,,,1603,DECLINE,131550,4451746,826,826,002,4, 00,CV2200,8,1,1,1,,,,
2. Where does channel come from and what's the content,
Ans: data in channel file(for AS2,DCP,KIVR and CCCD):
2893907 DCP
4451746 CCCD
4592242|4592267|4592275 KIVR

3.What does convert_dt.pl do
Ans:
convert_dt.pl:
Code:
#!/usr/bin/perl

$num_args = $#ARGV + 1;
die "Usage: this-program epochtime (something like '1219822177')" if
($num_args != 1);

$epoch_time = $ARGV[0];

($sec,$min,$hour,$day,$month,$year) = localtime($epoch_time);

# correct the date and month for humans
$year = 1900 + $year;
$month++;

printf "%02d-%02d-%02d %02d\n", $year, $month, $day, $hour;
4. what does convert_dt1.pl do
Ans:convert_dt1.pl:
Code:
#!/usr/bin/perl

$num_args = $#ARGV + 1;
die "Usage: this-program epochtime (something like '1219822177')" if
($num_args != 1);

$epoch_time = $ARGV[0];

($sec,$min,$hour,$day,$month,$year) = localtime($epoch_time);

# correct the date and month for humans
$year = 1900 + $year;
$month++;

printf "%02d%02d%02d%02d\n", $year, $month, $day, $hour;
5. What is the content of pay_dt.txt and pay_dt1.txt.

sample content for pay_dt.txt:
2013-12-19 05

Sample content for pay_dt1.txt
2013121905


6. Why is the loop present, i is never used inside the loop.
ANS: You are right this is never used.

7.Is this correct: tody=`ksh today`
Ans: ksh today
191213 (just showing date)

Last edited by santosh0782; 12-19-2013 at 03:30 AM.
 
Old 12-19-2013, 03:46 AM   #44
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
@santosh0782: You seem to have missed the important part of my previous reply:
Quote:
Originally Posted by druuna
In general: The whole script is build with a 1 hour time frame in mind which makes changing it into a 30 minute driven script rather hard (if not impossible). I would suggest having a good look at the data you have to start with (which seems to be the audit logs) and start fresh from there.
BTW: (ksh) today isn't a internal command. I'm guessing that today is a self written (ksh?) script. Be careful when using this. When using cron this might not be available.
 
Old 12-19-2013, 03:55 AM   #45
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
@santosh0782: You seem to have missed the important part of my previous reply:

BTW: (ksh) today isn't a internal command. I'm guessing that today is a self written (ksh?) script. Be careful when using this. When using cron this might not be available.
yes. today is a self written script
Code:
#!/bin/ksh

TT=$1
k=`date +%d%m%y`$TT
export k
echo "$k"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error running cron job, syntax error? mpyusko Debian 2 12-20-2012 09:57 AM
script.pl with sed shell calls: sh error syntax error near unexpected token `(' MMaddoxx Programming 7 11-24-2011 08:00 AM
syntax error on running configure file in cygwin sugan General 1 10-08-2010 01:34 AM
why am getting error ksh: syntax error: `fi' unexpected while running script deb4you Linux - Newbie 4 09-06-2008 08:37 AM
ERROR running make when installing Nvidia drivers (syntax error) randyriver10 Linux - Software 5 02-21-2004 04:51 PM


All times are GMT -5. The time now is 09:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration