Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

generate a report

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 08-20-2009
durden_tyler's Unix or Linux Image
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
 
Join Date: Apr 2009
Last Activity: 21 July 2015, 6:53 PM EDT
Posts: 1,904
Thanks: 9
Thanked 285 Times in 259 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 Unix and Linux 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 Unix and Linux 08-20-2009
durden_tyler's Unix or Linux Image
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
 
Join Date: Apr 2009
Last Activity: 21 July 2015, 6:53 PM EDT
Posts: 1,904
Thanks: 9
Thanked 285 Times in 259 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 Unix and Linux 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 Unix and Linux 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 Unix and Linux 08-21-2009
panyam panyam is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 8 December 2014, 6:40 AM EST
Posts: 1,159
Thanks: 20
Thanked 105 Times in 100 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 12:10 PM.