- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: doubt regarding mail message
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2007 07:32 AM
05-07-2007 07:32 AM
doubt regarding mail message
I am new to UNIX and actually I am not sure if I should be asking this question on this forum. But I ve been using this forum for HPOV and it is a super forum.
Well the doubt I ve got is ...
I need to write a script to monitor if an user gets a new mail.
When ever an User gets a new mail, I need to generate an alert in HPOV. This part I can do, but am not sure on how to check for new mails.
I checked for the command mail -e, but this option tells me if I have a mail in the mailbox or not.
I am looking for only new mails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2007 07:44 AM
05-07-2007 07:44 AM
Re: doubt regarding mail message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2007 07:50 AM
05-07-2007 07:50 AM
Re: doubt regarding mail message
But I need to run a script every fifteen minutes that would require to do this.
n if I check for the file under /var/mail/
I thought there would be an easier way to do this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2007 08:07 AM
05-07-2007 08:07 AM
Re: doubt regarding mail message
Initially, create a file which lists
/var/mail/username
for each users mailfile.
Something like thisi, myfile1.pl:
---------------------------------------
#!/usr/bin/perl -w
my $i = 0;
while ($i <= $#ARGV)
{
print $ARGV[$i],"\t",(stat($ARGV[$i])) [9],"\n";
++$i;
}
-------------------------------------
Invoke it like this:
perl myfile1.pl /var/mail/* > myreferencefile
Now your script will look for any files with newer modification times or files that are not in your reference files. After doing whatever operation you wish, you update the reference file with the new timestamps and any detected new files.
I'm not saying you must use Perl but it will be easy in Perl and a bit tricky in the shell because of the timestamp comparisons.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2007 08:37 AM
05-07-2007 08:37 AM
Re: doubt regarding mail message
But I was wondering,
When we logon, there appears a message that says "you have a new mail" which runs because of the profile.
There is a command that says
/bin/mail -E
case $? in
0)
echo "You have new mail."
;;
2)
echo "You have mail."
;;
esac
but I am unsure if this will satisfy my case,
because instead of echo "You have new mail", i can write the command to generate that alert.
Is this the same that I am looking at ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2007 09:02 AM
05-07-2007 09:02 AM
Re: doubt regarding mail message
mail -e
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "New mail"
fi
but this is specific to a user but I interpreted your question to mean detect when any user gets new mail. Since it's related to OV, I would much rather write one routine that handles all of my OV users and requires only 1 cron entry --- but that's just me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2007 09:21 AM
05-07-2007 09:21 AM
Re: doubt regarding mail message
I checked this option but echo $? returns a value of 0 even when the mail has been read.
I want to check only for new mails.
$? does not return a value of 2 at all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2007 09:36 AM
05-07-2007 09:36 AM
Re: doubt regarding mail message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2007 09:39 AM
05-07-2007 09:39 AM