Sponsored Content
Full Discussion: restarting a while loop
Top Forums UNIX for Dummies Questions & Answers restarting a while loop Post 38791 by nhatch on Friday 25th of July 2003 10:42:49 AM
Old 07-25-2003
Hi there,

This is the complete loop, should have posted to begin with (doesn't give away any secrets). I did the 1 = 1 cos I just want it run for ever or until the user kills it. It checks if the error is new if not goes on to report on it on screen if it isn't I want it to recheck after a brief pause.
Code:
while [ 1 = 1 ]
do 

clear

integer EXT=1
ALERTDIR=/var/opt/projects/mnp/logs/alerts
CURRENTLOG=$ALERTDIR/alert.log.$EXT

# Moving on until a file is found
until [  -s $CURRENTLOG ] 
do
        EXT=`expr $EXT + 1`     
        CURRENTLOG=$ALERTDIR/alert.log.$EXT
done


# Makes the substitution of the fields in the alert logs.
FIELDS=`cat $CURRENTLOG | sed -e 's/">/, /g' \
             -e 's/<\/OBJECT>/, /g'  \
             -e 's/<//g'`

echo $FIELDS > new_alert.tmp

diff new_alert.tmp last_alert.tmp
        if [ $? -eq 0 ]
        then 
                echo No new alert messsages `date`
                sleep 15 
                ???????;
        else
                continue;
        fi

CODE=`echo $FIELDS | cut -f2 -d,`
DATE=`echo $FIELDS | cut -f4 -d,`


if [ $CODE = "T004" ]
then
        echo $FIELDS | cut -f2,4,12,15,17 -d, \
        \
        | awk -F"," '{print  ""; \
        print "ALERT ID   :" $1; \
        print "TIMESTAMP  :" $2; \
        print "ERROR CODE :" $3; \
        print "MSISDN     :" $4; \
        print "ERROR      :" $5}'

elif [ $CODE = "T002" ]
then
        echo $FIELDS | cut -f2,4,12,15,17 -d, \
        \
        | awk -F"," '{print ""; \
        print "ALERT ID   :" $1; \
        print "TIMESTAMP  :" $2; \
        print "ERROR CODE :" $3; \
        print "MSISDN     :" $4; \
        print "ERROR      :" $5}'

else 
        echo $FIELDS | cut -f2, -d, \
        \
        | awk -F"," '{print  ""; \
        print "ALERT ID   :" $1}' 
        echo "Unknown ERROR type, check with 3rd line"
fi

echo File `basename $CURRENTLOG`

cp new_alert.tmp last_alert.tmp
sleep 5
done

Many thanks is advance....

Neil

added code tags for readability --oombera

Last edited by oombera; 02-19-2004 at 12:08 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Restarting a Crashed Process

Hello, I host a couple of Call of Duty gameing servers. There are some hackers who love the crash them. When they crash them it simply causes a segmentaion fault and kills the PID. I was wondering it you could help me write a script to simply restart the program after it has been crashed. The... (9 Replies)
Discussion started by: Phobos
9 Replies

2. UNIX for Dummies Questions & Answers

Restarting the Spooler

:confused: Everytime our UNIXWARE 7 Server is restarted we also have to restart the spooler. If the spooler is not restarted, print jobs get stuck in the queu. Once restarted by using the following command lpstop and lpstart everything works fine. Does anyone have any ideas what could be causing... (0 Replies)
Discussion started by: Yorgy
0 Replies

3. UNIX for Advanced & Expert Users

How to solve restarting problem

Hi! My unix os version is OSF1 CP1 V4.0 878 alpha. It startup normally but it restarts within 5 sec. I would like to know how to solve . Please reply to me. Thanks . akzin (2 Replies)
Discussion started by: akzin
2 Replies

4. SCO

System restarting itself every after 20-24 hours

HI We have Compaq ML350 G2 server with UNIX SCO 5.0.5 OS , can anyone help us to get rid about the system restarting problem by itself every after2-24 hours with following error " MEMORY CORE DUMP " . Waiting for your ASAP help. Thank You . (4 Replies)
Discussion started by: munirh
4 Replies

5. Solaris

server restarting

Hello people, My solaris server is rebooting, not sure how!!! Which log should I look in to? I checked /var/adm/messages and dmesg also. How do I check older dmesg logs? I checked lastlog and also ran the last command. Nothing useful pointing to why server rebooted. Also when server reboots I... (4 Replies)
Discussion started by: rcmrulzz
4 Replies

6. Solaris

Restarting syslogd on Unix

Hi All, I can seem to find the syslog daemon in the /etc/init.d/ dir. i have made change to the syslog.conf i need to restart the daemon. am using solaris 10. i have no problem on version 9 Anyone with a template i can use for log review for auditing purposes. (1 Reply)
Discussion started by: lottiem
1 Replies

7. Programming

Restarting the program

Hi, I use gfortran to run the code. Some times I need to stop the program and restart it. On restarting I need to run the program from the beginning. Is there any script or option available to restart the program from where it stopped? This script/option will be immensely useful for... (2 Replies)
Discussion started by: rpd25
2 Replies

8. UNIX for Dummies Questions & Answers

Restarting a process

Hi, How is it possible to restart only your process. I can get the process killed but I am not able to start it. For eg : i first did this ps -ef|grep _out --displays all the process with _out in the name then I killed kill -15 36044 -- process id. Now how can i start the same... (1 Reply)
Discussion started by: TH3M0Nk
1 Replies

9. Shell Programming and Scripting

Need help in restarting process

Hi friends, I have one unix command which is used to check the network status manually. followig is the command check_Network this command give follwoing status Network 1 is ok Network 2 is ok network 3 is ok network 4 is ok . . . . Network 10 is... (8 Replies)
Discussion started by: Nakul_sh
8 Replies

10. SuSE

Restarting syslog-ng

Environment: SUSE 10.3 I made a configuration change in '/etc/syslog-ng/syslog-ng.conf' file in a server. An article found on web says "After the change '/etc/init.d/syslog-ng' should be restarted". But there is no 'syslog-ng' in /etc/init.d directory. What is syslog-ng or a... (4 Replies)
Discussion started by: JDBA
4 Replies
VFS_PREALLOC(8) 														   VFS_PREALLOC(8)

NAME
vfs_prealloc - preallocate matching files to a predetermined size SYNOPSIS
vfs objects = prealloc DESCRIPTION
This VFS module is part of the samba(7) suite. The vfs_prealloc VFS module preallocates files to a specified size each time a new file is created. This is useful in environments where files are of a predetermined size will be written to a disk subsystem where extending file allocations is expensive. This module is stackable. OPTIONS
prealloc:EXT = BYTES Preallocate all files with the extension EXT to the size specified by BYTES. The following suffixes may be applied to BYTES: o K - BYTES is a number of kilobytes o M - BYTES is a number of megabytes o G - BYTES is a number of gigabytes EXAMPLES
A process writes TIFF files to a Samba share, and the is known these files will almost always be around 4 megabytes (4194304 bytes): [frames] path = /data/frames vfs objects = prealloc prealloc:tiff = 4M CAVEATS
vfs_prealloc is not supported on all platforms and filesystems. Currently only XFS filesystems on Linux and IRIX are supported. VERSION
This man page is correct for version 3.0.25 of the Samba suite. AUTHOR
The original Samba software and related utilities were created by Andrew Tridgell. Samba is now developed by the Samba Team as an Open Source project similar to the way the Linux kernel is developed. VFS_PREALLOC(8)
All times are GMT -4. The time now is 08:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy