generate a report | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

generate a report

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-20-2009
sailaja_80 sailaja_80 is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 25 August 2009, 1:19 PM EDT
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
generate a report

Hi

Please help me to resolve the below query.

My shell script has generated a file output.file like below
********************************
DROP TABLE GPS_CONTACT_DETAILS
DB20000I The SQL command completed successfully.
CREATE TABLE GPS_CONTACT_DETAILS ( CONTACT_ID VARCHAR(COUNTRY VARCHAR(20))
DB20000I The SQL command completed successfully.
********************************
Now

i have to generate a report like
GPS_CONTACT_DETAILS successfully

I am trying in all possible ways but not able to get this.
please help. Thanks for your help
Sponsored Links
    #2  
Old 08-20-2009
durden_tyler's Avatar
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
 
Join Date: Apr 2009
Last Activity: 20 September 2014, 10:54 PM EDT
Posts: 1,841
Thanks: 7
Thanked 266 Times in 241 Posts
Quote:
Originally Posted by sailaja_80 View Post
...
I am trying in all possible ways but not able to get this.
...
Post your attempts over here. Show us what you've tried so far.

tyler_durden
Sponsored Links
    #3  
Old 08-20-2009
sailaja_80 sailaja_80 is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 25 August 2009, 1:19 PM EDT
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks durden for your reply.
I am doing like below.

db2 -tvf "${var[Perforce_Script_Name]}" > $outdir
Is generating a file outdir liek this

DROP TABLE GPS_CONTACT_DETAILS
DB20000I The SQL command completed successfully.
CREATE TABLE GPS_CONTACT_DETAILS ( CONTACT_ID VARCHAR(30) )
DB20000I The SQL command completed successfully.

grep "successfully" $outdir >> $suc_Logfile
echo "${var[Object_Name]}" >> $suc_Logfile

generating file like this
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.

RMS_RPT_PERIOD_DIM

Now i need report.. like but i dotn know if we can do like this.

RMS_RPT_PERIOD_DIM Successful
abc successfull
as i was not able to do that.. i am tryign to send the lines where successfully word is not there to a different file

so i am trying like this...
grep -L "successfully" $suc_Logfile >> $Final_Suc
I tried to use awk command as well but was not successful


Thanks much for ur help
    #4  
Old 08-20-2009
durden_tyler's Avatar
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
 
Join Date: Apr 2009
Last Activity: 20 September 2014, 10:54 PM EDT
Posts: 1,841
Thanks: 7
Thanked 266 Times in 241 Posts
Your question and input data is way too confusing. Please wrap "code" tags around file contents, commands etc.

And show how the output you expect relates to your input file.

tyler_durden
Sponsored Links
    #5  
Old 08-20-2009
sailaja_80 sailaja_80 is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 25 August 2009, 1:19 PM EDT
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
My input file is like this.

DROP TABLE GPS_CONTACT_DETAILS
DB20000I The SQL command completed successfully.
CREATE TABLE GPS_CONTACT_DETAILS ( CONTACT_ID VARCHAR(30) )
DB20000I The SQL command completed successfully

Output file expecting is
DROP TABLE GPS_CONTACT_DETAILS successfully
CREATE TABLE GPS_CONTACT_DETAILS successfully
Sponsored Links
    #6  
Old 08-21-2009
ranjithpr ranjithpr is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 20 August 2010, 3:34 AM EDT
Posts: 175
Thanks: 0
Thanked 3 Times in 3 Posts
Hi Sailaja,

Below awk script can convert your sample input to sample output.


Code:
awk  ' $1 !~"^$" {print $1,$2,$3,"successfully."}' RS="successfully." file

But instead of success if there is any failure cases the script may give wrong result. Provide samples for failure also if any....

Regards,

Ranjith
Sponsored Links
    #7  
Old 08-21-2009
panyam panyam is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 24 July 2014, 3:48 AM EDT
Posts: 1,156
Thanks: 20
Thanked 104 Times in 99 Posts
Something like this :

Code:
awk '$0 ~ "successfully" { print q  " successfull" ;q=" ";next } $0 ~ "Fail"  { print q  "Failed" ;q=" ";next } { q = q " " $0 ; next } '  input_file.txt

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Generate report in HTML file from Oracle DB Amit.Sagpariya Shell Programming and Scripting 4 10-20-2008 05:47 AM
generate a program namishtiwari Programming 2 08-31-2007 04:09 AM
Help generate report from log files bucci Shell Programming and Scripting 4 08-24-2007 04:11 AM
need to generate support id.. sriram.s Solaris 2 02-06-2007 04:37 PM
Generate csv file rahulrathod Shell Programming and Scripting 4 01-23-2007 09:34 AM



All times are GMT -4. The time now is 06:11 PM.