![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Enhancing Script (using loops) to go through for each group | dolo21taf | Shell Programming and Scripting | 0 | 05-01-2008 12:12 AM |
| Mailing Problem | nimish | Shell Programming and Scripting | 2 | 12-02-2005 11:38 PM |
| mailing from a shell script | Selma | Shell Programming and Scripting | 2 | 05-17-2005 04:23 AM |
| Mailing an attachment | gayath3 | Shell Programming and Scripting | 0 | 03-18-2005 06:09 AM |
| Mailing thru UNIX shell script | navin | UNIX for Advanced & Expert Users | 2 | 08-10-2002 10:46 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to check if a new line has been added to a file
Hi all..
I'm not a scripter but I'm trying to set up a mail script that emails out once a file has been written to. Is there some way of writing a while read loop or something, so that it reads each line of the file and then ends when a specific number of lines have been written... We're going to have 10 or 20 scripts that write to the file saying script_1 started at $(date) script_2 started at $(date) script_1 ended at $(date) and so on.. I don't know whether I should put some sort of trigger in the file to indicate that its the end of the file or because i know how many lines will be there just to put some sort of counter in the loop. Edit: Using .ksh Last edited by Jazmania; 03-26-2009 at 04:16 AM.. |
|
||||
|
Here you can try this...
DATE=`/bin/date '+%m%d%y'` MESSAGE="Found Error on XYZ " MAILTO="A-team" cd /home/alert errfile="/home/alert/alert.2b.txt" if [[ -e ${errfile} ]] ; then cat $errfile | mailx -s "$MESSAGE" $MAILTO fi mv /home/alert/alert.2b.txt /home/alert/alert.2b.txt_$DATE |
|
||||
|
How to check if a new line has been added to a file?
Ok your code works but its not exatly what I'm lookin for.. What the script to continuously look in the file and email out when a new line has been found.. the script will then email out the first word of the new line I've tried to to it this way but no luck Code:
OUTPATH=/home/out PARMFILE=$OUTPATH/jobcount_test.txt LOG=$OUTPATH/job_count_monthlymail_log.txt HLOG=$OUTPATH/job_count_monthlymail_hlog.txt # echo " started at $(date)" > $LOG # integer count=0 while [[ $count < 2 ]] do body_msg=`tail -1 $PARMFILE` mailx -s "$body_msg" jarrathy@notes < $body_msg ((count = count +1)) done ## echo " ended at $(date)" >> $LOG cat $LOG >> $HLOG I was updating the jobcount_test.txt and was hoping when i had two lines in there the job would stop but it didn't.. can someone tell me what i'm doing wrong? Last edited by Jazmania; 03-26-2009 at 04:14 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|