Sponsored Content
Top Forums Shell Programming and Scripting Need exception handle for this script Post 302928380 by Mathew_paul on Thursday 11th of December 2014 08:53:17 AM
Old 12-11-2014
Need exception handle for this script

Hi

This is script to move log files from one location to other which is working fine. I need to add exception handling in this new to scripting. Please help
Code:
#!/bin/ksh
DB=QACCABOP
dumppath='/udb/udbpa032/dump_data/offshore/Tran_logs'
msg='/udb/udbpa032/utilities/DBAscripts/msg/msg.out'

logpath1=`db2 get db cfg for $DB | grep -i 'Path to log files' | grep -v Changed | awk ' { print $6 } ' `

ACTIVELOG=`db2 get db cfg for $DB | grep -i 'First active log file' | awk ' { print " ls -ltr | grep " $6 } ' | sh - | awk ' { print  $9 } '`

cd $logpath1
logfilper=`df -gt . | grep log | awk ' { print $5 } ' | rev | cut -c 2- | rev`

if [ $logfilper -ge 50 ];then
   echo "-------------Moving old logs to dump ----------" `date +%Y-%m-%d-%H.%M.%S`  >> $msg
   #FIRSTLOG=`ls -ltr *.LOG | head -n 1 | awk ' { print $9 } '`
   #echo "Oldest log in the directory $FIRSTLOG"
   find . -newer SQLLPATH.TAG \! -newer $ACTIVELOG | grep -v $ACTIVELOG | awk ' { print "mv" " " $0 " "  \
   "/udb/udbpa032/dump_data/offshore/Tran_logs" } ' | sh -
   cd $dumppath
   ls -ltr *.LOG | awk ' { print "gzip " " " $9 } ' | sh -
   find . -name "*.LOG" -mtime +7 | awk ' { print "rm " $0 } ' | sh -
else
   echo "--------------- FS is below threshold --------"  `date +%Y-%m-%d-%H.%M.%S`  >> $msg
   exit 0 
fi


Moderator's Comments:
Mod Comment Please use code tags for your code and data, thanks

Last edited by vbe; 12-11-2014 at 12:56 PM.. Reason: indent...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to handle errors during script execution

Hi I have written a script which returns a number. This resulting number I assign to the variable for example: $ A=`get_dbnum 118 ttrn` $ echo ${A} 8208 $ The script becomes interective once the error occures and the number is not found. It prompts the user to enter the number. The... (1 Reply)
Discussion started by: aoussenko
1 Replies

2. Shell Programming and Scripting

Shell Script to Handle Quarterly Backup.

Hi I'm not to shell script and I'm trying to write a simple shell code to do the following. Shell script should be run in March, June, Sept, & Dec respectively to back up files last modified in the 1st, 2nd, 3rd, and 4th quarters. I've have the following code. #!/bin/csh set v1 = `date... (1 Reply)
Discussion started by: Magshabib@gmail
1 Replies

3. Shell Programming and Scripting

Database handle to a child script using exec

Hello, Can I pass a database handle created in parent script to a child script triggered using exec ?? Parent script ========= $dbh =DBI->connect{......); # Db handle creation $param1 =10; # parameter one exec "childscript.pl $param1 $dbh "; # executing childscript.pl with two parameters... (0 Replies)
Discussion started by: coolbhai
0 Replies

4. Shell Programming and Scripting

i'm new to shell can handle this script for me plz

Write a shell script named displayargs that prints FOUR lines. The first line tells the name that was used to invoke the script, the second line tells how many parameters there were, the third line tells what the last parameter was, and the fourth line tells what the first parameter was. For... (8 Replies)
Discussion started by: kedah160
8 Replies

5. Shell Programming and Scripting

help to handle the expect script issue

Hi experts I know the expect script can match the terminal output to run the the following cmd I write a script with expect named "test", I want to run ten "test" with background running, for ((i=1;i<=10;i++) do ./test -n $i done I find all the output of test will print on one... (0 Replies)
Discussion started by: yanglei_fage
0 Replies

6. Shell Programming and Scripting

how to handle , in data where separator also commas in awk script

TEST_HEME,"SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1",CELL when I split by FS="," then $0=TEST_HEME $1="SubNetwork=ONRM_RootMoR $2=SubNetwork=ARNC1" but I need this will be single value "SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1" (4 Replies)
Discussion started by: Hemendra
4 Replies

7. UNIX for Dummies Questions & Answers

Difference between handle to the thread HANDLE and thread identifier pthread_t

This question might be silly but its confusing me a bit: What is the difference between handle to the thread HANDLE and thread identifier pthread_t? ---------- Post updated at 01:52 PM ---------- Previous update was at 01:48 PM ---------- Sorry I saw details and HANDLE is in windows and... (0 Replies)
Discussion started by: rupeshkp728
0 Replies

8. Shell Programming and Scripting

Handle occasional condition in expect script

Hi, I am using Solaris OS, I want to handle an occasional expression in expect script while logging into a remote server with ssh. In normal scenario the expected expression is as below, spawn ssh $user@$ip expect "assword:" send "$password\r" but in a condition when the remote server... (2 Replies)
Discussion started by: varunksharma87
2 Replies

9. Shell Programming and Scripting

Shell script to unmonitor the mounts in exception file

I am trying to write a shell script for monitoring the file system mount. command I am using will retrieve a output as shown below. /dev/fsv29 2% /apps/rj/pgl/bslSys I also need to add exception mounts in a file and I would like script to ignore the mount which I specify. If I add the... (6 Replies)
Discussion started by: chandu123
6 Replies

10. Shell Programming and Scripting

Monitor logs for exception and if exception come then sent an email

Hi Folks, please advise , I have logs generated on unix machine at location /ops/opt/aaa/bvg.log , now sometimes there come exception in these logs also, so I want to write such a script such that it should continuously monitor these logs and whenever any exception comes that is it try to find... (3 Replies)
Discussion started by: tuntun27272727
3 Replies
DDB(8)							    BSD System Manager's Manual 						    DDB(8)

NAME
ddb -- configure DDB kernel debugger properties SYNOPSIS
ddb capture [-M -core] [-N -system] print ddb capture [-M -core] [-N -system] status ddb script scriptname ddb script scriptname=script ddb scripts ddb unscript scriptname ddb pathname DESCRIPTION
The ddb utility configures certain aspects of the ddb(4) kernel debugger from user space that are not configured at compile-time or easily via sysctl(8) MIB entries. To ease configuration, commands can be put in a file which is processed using ddb as shown in the last synopsis line. An absolute pathname must be used. The file will be read line by line and applied as arguments to the ddb utility. Whitespace at the beginning of lines will be ignored as will lines where the first non-whitespace character is '#'. OUTPUT CAPTURE
The ddb utility can be used to extract the contents of the ddb(4) output capture buffer of the current live kernel, or from the crash dump of a kernel on disk. The following debugger commands are available from the command line: capture [-M core] [-N system] print Print the current contents of the ddb(4) output capture buffer. capture [-M core] [-N system] status Print the current status of the ddb(4) output capture buffer. SCRIPTING
The ddb utility can be used to configure aspects of ddb(4) scripting from user space; scripting support is described in more detail in ddb(4). Each of the debugger commands is available from the command line: script scriptname Print the script named scriptname. script scriptname=script Define a script named scriptname. As many scripts contain characters interpreted in special ways by the shell, it is advisable to enclose script in quotes. scripts List currently defined scripts. unscript scriptname Delete the script named scriptname. EXIT STATUS
The ddb utility exits 0 on success, and >0 if an error occurs. EXAMPLES
The following example defines a script that will execute when the kernel debugger is entered as a result of a break signal: ddb script kdb.enter.break="show pcpu; bt" The following example will delete the script: ddb unscript kdb.enter.break For further examples, see the ddb(4) and textdump(4) manual pages. SEE ALSO
ddb(4), textdump(4), sysctl(8) HISTORY
The ddb utility first appeared in FreeBSD 7.1. AUTHORS
Robert N M Watson BUGS
Ideally, ddb would not exist, as all pertinent aspects of ddb(4) could be configured directly via sysctl(8). BSD
December 24, 2008 BSD
All times are GMT -4. The time now is 03:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy