Scripting job to complete


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripting job to complete
# 8  
Old 04-18-2011
This should help you

Code:
#!/bin/ksh
for i in    `grep  -n "CDR" cdr.txt |awk -F ':' '{print $1}'`
do
  i=`expr $i + 2`
  idx=`expr $i + 5`
  echo `sed -n  "$i","$idx"p cdr.txt|awk  '{print $2}'|tr "\n" " " |awk -F ' ' '{print $1 "|" $2 "|" $3 "|" $4 "|" $5 }'` >>newfile.dat
done


Last edited by palanisvr; 04-18-2011 at 03:17 AM.. Reason: identification string has changed.
This User Gave Thanks to palanisvr For This Post:
# 9  
Old 04-18-2011
you should be able to write at least part of this script by yourself by now, don't you think?
This User Gave Thanks to pbillast For This Post:
# 10  
Old 04-18-2011
3 things still needed in the script

Quote:
Originally Posted by palanisvr
Code:
#!/bin/ksh
for i in    `grep  -n "CDR" cdr.txt |awk -F ':' '{print $1}'`
do
  i=`expr $i + 2`
  idx=`expr $i + 5`
  echo `sed -n  "$i","$idx"p cdr.txt|awk  '{print $2}'|tr "\n" " " |awk -F ' ' '{print $1 "|" $2 "|" $3 "|" $4 "|" $5 }'` >>newfile.dat
done

Hi,

This is my script.
Code:
[root@FLPROVP01 cdr]# cat t.sh
#!/bin/ksh
sed 's/^[ \t]*//' cdr.txt > cdr_1.txt
sed '/^$/d' cdr_1.txt > cdr_2.txt
for i in `grep -n "-" cdr_2.txt |awk -F ':' '{print $1}'`
do
     idx=`expr $i + 15`
     echo `sed -n "$i","$idx"p cdr_2.txt|awk '{print $2}'|tr "\n" " " |awk -F ' ' '{print $1 "|" $2 "|" $3 "|" $4 "|" $5 "|" $6 "|" $7 "|" $8 "|" $9 "|" $10 "|" $11 "|" $12 "|" $13 "|" $14"|" $15}'` >>o.txt
done

3 things still needed in the script.

A] The script should ignore the lines:

listOfTrafficVolumes
qosNegotiated

B] One of the parameter in Filed 1 is Alloc./Retention priority. It contains a ./ & it should not affect script processing.

C] The script should be able to display the following type of values properly.
Code:
 
0x0C (12)
0x1 (Delay class 1)
etc.

i am atatching the actual input file cdr.txt again.

Thanks,
Sunil

Moderator's Comments:
Mod Comment You were asked by Franklin52 already to use code tags. Please use [code] and [/code] tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks.

Last edited by zaxxon; 04-18-2011 at 04:36 AM.. Reason: code tags
# 11  
Old 04-18-2011
Try with the updated one .


Code:
#!/bin/ksh
for i in    `grep  -n "CDR" cdr.txt |awk -F ':' '{print $1}'`
do
  i=`expr $i + 2`
  idx=`expr $i + 5`
  echo `sed -n  "$i","$idx"p cdr.txt|awk  '{print $2}'|tr "\n" " " |awk -F ' ' '{print $1 "|" $2 "|" $3 "|" $4 "|" $5 }'` >>newfile.dat
done

It should ignore the below and writes the fabricated data into newfile.dat file. delete the file before running this script else it would append to the same.


3 things still needed in the script.

A] The script should ignore the lines:

listOfTrafficVolumes
qosNegotiated

B] One of the parameter in Filed 1 is Alloc./Retention priority. It contains a ./ & it should not affect script processing.

C] The script should be able to display the following type of values properly.

0x0C (12)
0x1 (Delay class 1)
etc.
This User Gave Thanks to palanisvr For This Post:
# 12  
Old 04-18-2011
Output is not proper

Quote:
Originally Posted by palanisvr
Try with the updated one .


Code:
#!/bin/ksh
for i in    `grep  -n "CDR" cdr.txt |awk -F ':' '{print $1}'`
do
  i=`expr $i + 2`
  idx=`expr $i + 5`
  echo `sed -n  "$i","$idx"p cdr.txt|awk  '{print $2}'|tr "\n" " " |awk -F ' ' '{print $1 "|" $2 "|" $3 "|" $4 "|" $5 }'` >>newfile.dat
done

It should ignore the below and writes the fabricated data into newfile.dat file. delete the file before running this script else it would append to the same.


3 things still needed in the script.

A] The script should ignore the lines:

listOfTrafficVolumes
qosNegotiated

B] One of the parameter in Filed 1 is Alloc./Retention priority. It contains a ./ & it should not affect script processing.

C] The script should be able to display the following type of values properly.

0x0C (12)
0x1 (Delay class 1)
etc.
Hi,

The output is fine till 9 rows. After that the following rows are not processed properly.

Code:
Length 0x0C (12)
Alloc./Retention priority 0x01 (1)
Delay class 0x1 (Delay class 1)
Reliability class 0x3 (Unack. GTP/LLC, Ack. RLC, 
Protected data)
Peak throughput 0x04 (Up to 8000 oct/s)

Following is my script.

Code:
[root@FLPROVP01 cdr]# cat t.sh
#!/bin/ksh
sed 's/^[ \t]*//' cdr.txt > cdr_1.txt
sed '/^$/d' cdr_1.txt > cdr_2.txt
for i in `grep -n "CDR" cdr.txt |awk -F ':' '{print $1}'`
do
i=`expr $i + 2`
idx=`expr $i + 25`
echo `sed -n "$i","$idx"p cdr_2.txt|awk '{print $2}'|tr "\n" " " |awk -F ' ' '{print $1 "|" $2 "|" $3 "|" $4 "|" $5 "|" $6 "|" $7 "|" $8 "|" $9 "|" $10 "|" $11 "|" $12 "|" $13 "|" $14 "|" $15 "|" $16 "|" $17 "|" $18 "|" $19 "|" $20 "|" $21 "|" $22 "|" $23 "|" $24 "|" $25}'` >>o.txt
done

Thanks,
Sunil

Moderator's Comments:
Mod Comment code tags are written inside [ and ], not < and >.

Last edited by zaxxon; 04-18-2011 at 04:53 AM.. Reason: code tags
# 13  
Old 04-18-2011
I could find in the script that you are refering to incorrect file in the grep condition , I have changed it accordingly, try with this.

Code:
#!/bin/ksh
sed 's/^[ \t]*//' cdr.txt > cdr_1.txt
sed '/^$/d' cdr_1.txt > cdr_2.txt
for i in `grep -n "CDR" cdr_2.txt |awk -F ':' '{print $1}'`
do
i=`expr $i + 2`
idx=`expr $i + 25`
echo `sed -n "$i","$idx"p cdr_2.txt|awk '{print $2}'|tr "\n" " " |awk -F ' ' '{print $1 "|" $2 "|" $3 "|" $4 "|" $5 "|" $6 "|" $7 "|" $8 "|" $9 "|" $10 "|" $11 "|" $12 "|" $13 "|" $14 "|" $15 "|" $16 "|" $17 "|" $18 "|" $19 "|" $20 "|" $21 "|" $22 "|" $23 "|" $24 "|" $25}'` >>o.txt
done

This User Gave Thanks to palanisvr For This Post:
# 14  
Old 04-18-2011
Output is not still proper

Quote:
Originally Posted by palanisvr
I could find in the script that you are refering to incorrect file in the grep condition , I have changed it accordingly, try with this.

Code:
#!/bin/ksh
sed 's/^[ \t]*//' cdr.txt > cdr_1.txt
sed '/^$/d' cdr_1.txt > cdr_2.txt
for i in `grep -n "CDR" cdr_2.txt |awk -F ':' '{print $1}'`
do
i=`expr $i + 2`
idx=`expr $i + 25`
echo `sed -n "$i","$idx"p cdr_2.txt|awk '{print $2}'|tr "\n" " " |awk -F ' ' '{print $1 "|" $2 "|" $3 "|" $4 "|" $5 "|" $6 "|" $7 "|" $8 "|" $9 "|" $10 "|" $11 "|" $12 "|" $13 "|" $14 "|" $15 "|" $16 "|" $17 "|" $18 "|" $19 "|" $20 "|" $21 "|" $22 "|" $23 "|" $24 "|" $25}'` >>o.txt
done

Thank you so much for helping me. Below is the output after modifying the script. This output is still missing many many fields.

Code:
EGSNPDPRECORD|405150016945607|115.255.8.82|626709187|220.224.141.18|rcomwap|IPV4|10.88.79.121|TRUE|0x0C|priority|class|class|throughput|class|throughput|class|order|of|SDU|bit|bit|BER|error|
EGSNPDPRECORD|405210010858247|115.255.8.82|626709171|220.224.141.85|rcomwap|IPV4|10.88.96.179|TRUE|0x0C|priority|class|class|throughput|class|throughput|class|order|of|SDU|bit|bit|BER|error|
EGSNPDPRECORD|405060031074049|115.255.8.82|626709196|115.255.8.81|rcommms|IPV4|10.94.34.193|TRUE|0x0C|priority|class|class|throughput|class|throughput|class|order|of|SDU|bit|bit|BER|error|
EGSNPDPRECORD|405060031074049|115.255.8.82|626707737|115.255.8.81|rcomwap|IPV4|10.88.97.57|TRUE|0x0C|priority|class|class|throughput|class|throughput|class|order|of|SDU|bit|bit|BER|error|

The output of the lenght field should be '0x0C (12)'. But it is coming only as 0x0C & after that the rest of the output is not as expected. The rest of the fields after that have output in similar format like '0x1 (Delay class 1)' , '0x3 (Unack. GTP/LLC, Ack. RLC, Protected data)' etc.

My current script is:

Code:
[root@FLPROVP01 cdr]# cat t_new.sh
#!/bin/ksh
sed 's/^[ \t]*//' cdr.txt > cdr_1.txt
sed '/^$/d' cdr_1.txt > cdr_2.txt
for i in `grep -n "CDR" cdr_2.txt |awk -F ':' '{print $1}'`
do
i=`expr $i + 2`
idx=`expr $i + 25`
echo `sed -n "$i","$idx"p cdr_2.txt|awk '{print $2}'|tr "\n" " " |awk -F ' ' '{print $1 "|" $2 "|" $3 "|" $4 "|" $5 "|" $6 "|" $7 "|" $8 "|" $9 "|" $10 "|" $11 "|" $12 "|" $13 "|" $14 "|" $15 "|" $16 "|" $17 "|" $18 "|" $19 "|" $20 "|" $21 "|" $22 "|" $23 "|" $24 "|" $25}'` >>o.txt
done
[root@FLPROVP01 cdr]#

Thanks,
Sunil
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automation script for email alert when a job get complete with status successful.

Guyz, Please let me know about script which is to be sending an automatic email to particular mail id's when a monotoring job get complete with status successful. (1 Reply)
Discussion started by: Rehan Ahmad
1 Replies

2. Shell Programming and Scripting

To refire a backup job using shell scripting..........

how to write a code using shell scripting to refire a back up job if it fails with an error code of 196? (7 Replies)
Discussion started by: Pawan Ramnani
7 Replies

3. Shell Programming and Scripting

I want a script to view the complete log information of data stage job from UNIX IBM AIX.

Hi, I am working on data stage 8.7 version and I want a script a to view the all log information of the data stage job from UNIX environment. Can you please help me out by give the script. Thanks in advance... (7 Replies)
Discussion started by: victory
7 Replies

4. Windows & DOS: Issues & Discussions

AutoSys Job not waiting for script to complete

I'm not sure if this is the right place to post this issue...but here goes... I am converting a set of windows jobs from Control-M to AutoSys r11.3. The same command line is being executed in both systems. The Control-M job runs to compltion in about 1.5 hours, waiting for the entire batch... (3 Replies)
Discussion started by: ajomarquez
3 Replies

5. Shell Programming and Scripting

Unix Scripting : Sort a Portion of a File and not the complete file

Need to sort a portion of a file in a Alphabetical Order. Example : The user adam is not sorted and the user should get sorted. I don't want the complete file to get sorted. Currently All_users.txt contains the following lines. ############## # ARS USERS ############## mike, Mike... (6 Replies)
Discussion started by: evrurs
6 Replies

6. Post Here to Contact Site Administrators and Moderators

Where can I download the VTC - Unix Shell Scripting Advanced complete video

Where can I download the VTC - Unix Shell Scripting Advanced complete video. I don't know in which thread I should post this question.Plz help me out, or just tell me the link in the reply to this post. Thanks in advance. (0 Replies)
Discussion started by: villain41
0 Replies

7. Shell Programming and Scripting

How to schedule a job in shell scripting.

Hi all I have made a shell script to check jobs' status and send an alert based on the result. I want to run this script to run every 4 hours and I don't have access to cron. Can we schedule using shell scripting instead of cron facility? (2 Replies)
Discussion started by: johnl
2 Replies

8. UNIX for Advanced & Expert Users

At job in SHELL SCRIPTING

Hi I am using at job in my SHELL scripts.. When it prompts to enter the time for at job..I used to press enter(return) button.. After that its running the job properly, but its showing the below error UX:at: ERROR: Bad date specification.. Can some one suggest how to remove that error. ... (2 Replies)
Discussion started by: grajesh_955
2 Replies

9. Windows & DOS: Issues & Discussions

windows scripting for a batch job

I have been doing unix scripting for quite awhile and there seems to be a wealth of information on it. Now I am working on migrating an intel based application to a new server. I need to modify some existing scripts, but am having trouble finding information on windows scripting, a forum similar... (2 Replies)
Discussion started by: MizzGail
2 Replies

10. Shell Programming and Scripting

start job after complete transfer....

Hi, I have a situation... I have a script it checks for a file in a folder which comes to the folder every day at specified time...2am to 4 am, once the file is in the polder my process starts...but the problem is the files being placed are huge and it is even taking half an hour for the file... (3 Replies)
Discussion started by: mgirinath
3 Replies
Login or Register to Ask a Question