Sponsored Content
Top Forums UNIX for Advanced & Expert Users concurrency issue while Accessing Mail Box from shell script Post 302108237 by Sumit_Fundoo on Sunday 25th of February 2007 07:42:16 AM
Old 02-25-2007
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
 

10 More Discussions You Might Find Interesting

1. HP-UX

Accessing databases using sql*plus on HP box

When I try to connect to databse from HP box using the following command sqlplus <username>@<databasename> I get this error message: ksh: <database name> : not found I can connect to the database outside the UNIX box using sqlplus though. Looks like the problem is the way HP Unix is... (4 Replies)
Discussion started by: dtonse
4 Replies

2. Shell Programming and Scripting

Box A's perl script calling box B's shell script

Hi all, i have a perl script one server. I am running a cronjob to execute my perl script. #! /usr/bin/perl ... ... ... #call a shell script on another server How can i accomplish #? Do i have to issue a system (" ssh -l username server | shellscript.sh") in my shell script? or is there a... (1 Reply)
Discussion started by: new2ss
1 Replies

3. Shell Programming and Scripting

Accessing the parameters of a shell script

Hi, I have one situation. I am developing a shell script to which parameters will be passed from a Web based User Interface using some Business Process(BP).There are some 6 parameters for which user will enter the values in UI. These values will be passed to script by BP in the form -... (2 Replies)
Discussion started by: The Observer
2 Replies

4. Shell Programming and Scripting

Accessing aliases within a shell script

I am not able to access the aliases in my environment within a Python script. If I pass the alias to os.system(), I get a message saying "sh: x: not found". I've tried sourcing my .bashrc file in the script, but this does not work. I would perfer not to source my or any rc file because this... (9 Replies)
Discussion started by: cooldude
9 Replies

5. UNIX for Dummies Questions & Answers

unix script to check if rsh to box and send status mail

rshstatus=`rsh -n lilo /db/p2/oracle/names9208/restart_names.sh` if $rshstatus <>0 then errstatus=1 mailx -s "xirsol8dr" ordba@xxx.com >> $log_dr else if errstatus=0 echo "status to xirsol8dr successful" can anyone provide if this is t he correct way to do this or is there a better way? (1 Reply)
Discussion started by: bpm12
1 Replies

6. Shell Programming and Scripting

ftp file starting with particular name on Windows box to Unix box using shell script

Hello all ! I'm trying to write a shell script (bash) to ftp a file starting with particular name like "Latest_" that is present on a Windows box to UNIX server. Basically I want to set this script in the cron so that daily the new build that is posted on the Windows box can be downloaded to the... (2 Replies)
Discussion started by: vijayb4u83
2 Replies

7. Web Development

Accessing a Perl CGI script, security issue

Hi Everybody, I was wondering if it was possible for someone to gain access to my Perl CGI scripts before they are interpreted by Perl (mod_perl on apache2) i.e. getting a hold of my raw scripts and not the html output? Let's say I use the DBI module where I have the hostname, user and... (2 Replies)
Discussion started by: z1dane
2 Replies

8. Solaris

Mail system Configuration issue on UNIX box

Hi, I wanted to configure a mail system on my UNIX box. For that I read a document Sun Internet Mail Server 3.5 Advanced Installation Guide: Contents which is actually quite useful document but I am not sure from where can I bring patch? Is this patch will come in any CD form which I need to run... (1 Reply)
Discussion started by: Dhruvak
1 Replies

9. Shell Programming and Scripting

Clean up UNIX mail box using script

Hi, I would like to clean up by unix mail mail box thru some script command.. I do know how to delete from mail box ... e.g. $ mail ? d* ? quit But I need to clean up thru some command which I can use in my script before sending any email.. Thanks in advance! (1 Reply)
Discussion started by: pareshkp
1 Replies

10. Open Source

Shell script file movement to a Mail Box server using ftp commands

Hi All, I have a current Process that runs "windows script " for the file movement that needs to changed to a "DataStage Process (Using shell script )" Source :Text file is getting generated as part of Datastage Jobs processes and resides in a shared drive (Unix server) Target :ftp... (2 Replies)
Discussion started by: developer.dwh9
2 Replies
thr_getconcurrency(3C)					   Standard C Library Functions 				    thr_getconcurrency(3C)

NAME
thr_getconcurrency, thr_setconcurrency - get or set thread concurrency level SYNOPSIS
cc -mt [ flag... ] file...[ library... ] #include <thread.h> int thr_setconcurrency(int new_level); int thr_getconcurrency(void); DESCRIPTION
These functions are obsolete and maintained for compatibility only. The thr_setconcurrency() function updates the desired concurrency level that libthread maintains for the calling process. This value does not affect the behavior of the calling process. The thr_getconcurrency() function returns the current value for the desired concurrency level. RETURN VALUES
The thr_getconcurrency() function always returns the current value for the desired concurrency level. If successful, the thr_setconcurrency() function returns 0. Otherwise, a non-zero value is returned to indicate the error. ERRORS
The thr_setconcurrency() function will fail if: EAGAIN The specified concurrency level would cause a system resource to be exceeded. EINVAL The value for new_level is negative. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
thr_create(3C), attributes(5), standards(5) SunOS 5.10 11 May 1998 thr_getconcurrency(3C)
All times are GMT -4. The time now is 01:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy