The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Accessing variables of one shell script in another shell script rsendhilmani Shell Programming and Scripting 2 03-17-2009 01:17 AM
Accessing PL/SQL OUT variables in Korn Shell Script bright_future UNIX for Advanced & Expert Users 4 12-02-2008 12:02 PM
accessing shell script variable in file HIMANI UNIX for Dummies Questions & Answers 6 08-07-2007 12:07 AM
Accessing var from .profile into shell script videsh77 Shell Programming and Scripting 7 05-28-2005 01:21 PM
Accessing the home directory in shell script krishan SUN Solaris 1 05-21-2005 01:41 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-25-2007
Sumit_Fundoo Sumit_Fundoo is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 1
concurrency issue while Accessing Mail Box from shell script

Hi Bros,

I am in a serious trouble with concurrency issue while using mailx. I have a shell script which reads all the emails of a unix user account and create a copy (another mbox for processing and archive purpose). This script works fine for 99.99% of the time but sometime it start creating multiple copies of the same email during creation of another temp mail box copy and subsequently results in large repetitive insert database calls.

This email loading shell script is a regular cron job which runs after every 30 minutes. My doubts goes to somebody running mailx command or reading email of the same user account while Email Loader is running. Am i correct with my doubt ? Is there anyways to explicit lock the unix user mailbox while my Email Loader program is running ? please advise if i am wring somewhere in script.

I am also providing code snippet here -
# Functions for checking whether there is any emails in user mailbox - returns 0 in variable mailstat if there are new emails in mailbox otherwise 1.


Code:
check_mailbox()
{
 if [ "$mailfile" = "" ]; then  
    mailx -e
 else
   #mailx -e -f $mailfile
    if [ -f "$mailfile" ]; then  
       mailstat=0
     else
       mailstat=1
    fi
 fi
 mailstat=$?
} # check_mailbox  

#### main Block which is running and creating a copy of all mails in users mailbox.


------------
/* mail file is always blank as we never pass any argument to script.*/
mailfile="$1"  

echo "Test to see if there is mail. Exit status will be 0 if there is." >> $logfile
check_mailbox
if [ $mailstat -eq 1 ]; then
   echo "No mails exist in mailbox" >> $logfile
   exit 1
fi

echo "Archiving Mailbox." >> $logfile
touch  ${mailboxarchive} 

while ( [ $mailstat -eq 0 ] )
do
  echo "save ${mailboxarchive}
        quit" > $exmailfl
  if [ "empty$mailfile" = "empty" ]; then
     mailx < $exmailfl > $outfile
  else
    if [ ! -f $mailfile ]; then
      # all done
       break
    fi
    mailx -f $mailfile < $exmailfl > $outfile
  fi
  check_mailbox
done


anybody have any clue on where i am doing foolish act ? any help bros

looking forward for some unix experts help (i m a j2ee guy and don't have that depth in Unix schell scripting)

Thx in well advance.
Sumit

Last edited by Perderabo; 02-25-2007 at 12:58 PM.. Reason: Add code tags for readability
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0