If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Script to move these files that encountered unknown exceptions to a specific

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-22-12, 06:00
Lavanya123 Lavanya123 is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
Script to move these files that encountered unknown exceptions to a specific

Hi,

Iam still a begineer in Linux shell scripting...here's the assigment which i have to finish by 12 hours. Please help me out in scripting

Content of my log:

20120118073450|ERROR |job2214153_3eb0de2fa1c08bf4b405cf7769b1dac0| 1|Salience error enhancing asset (Unknown exception.) [/san/clients/rmv/lxa/job2214153/docs/pending/20120114/Dialog/DIA-0131753379.xml]


See the logs for unknown exceptions. I want a script to move these files that encountered unknown exceptions to a specific folder.

Once could invoke your script in command line giving 2 arguments 1. log and 2. which folder the files should be moved to.

its very urgent please help me any help is greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old 01-23-12, 12:01
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool

Use "awk" to extract the file name and then "mv" to move to neew folder.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 01-23-12, 23:47
Lavanya123 Lavanya123 is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
Used the followiing iam getting error.

for i in `awk '/Unknown exception/ {print gensub(/.*\(Unknown exception.\) \[(.+)\].*/, \\\1, \$0))’ $1`

do

echo “mv ${i} $2”

done

awk should return the following from the log file:

/san/clients/rmv/lxa/job2214153/docs/pending/20120114/Dialog/DIA-0131753369.xml
Reply With Quote
  #4 (permalink)  
Old 01-24-12, 09:18
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Code:
grep "Unknown exception" logfile|while read line 
do                                         
 file=`echo $line|cut -d"[" -f2`           
 file=`echo $file|cut -d"]" -f1`           
 echo $file                                
done
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On