Sponsored Content
Top Forums Shell Programming and Scripting How to read email using mailx in shell script or perl Post 302177231 by jliharper on Thursday 20th of March 2008 11:09:56 AM
Old 03-20-2008
How to read email using mailx in shell script or perl

Hello,

I am new to mailx and perl and I need help.

I need create a shell script to read the mails on the SUN server, then parse the subject line and message body of each email to extract particular data so that I can pass these data fields in as application parameters to invoke a java client application from the script. This logic need to be run every so many minutes to check for new email in the user's system mailbox.

I was thinking of using mailx in shell script. Is there a way I can parse the mail stream and pipe the extracted data to the java application inside mailx? Or do I have to copy the mail into a file, exit/quit mailx, then process the contents in the file later from the shell script? Or is there a better way using Perl?

Thank you!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unable to do mailx from shell script

Hi From within a shell script my mailx doesnt seem to work...can somebody tell me what is wrong... #!/bin/ksh #Script to verify wheather all databases listed are up and running #Script works with Oracle8 and above databases #Script has to be run by ./scriptname DBA=xiamin@unix.com echo... (3 Replies)
Discussion started by: xiamin
3 Replies

2. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies

3. Shell Programming and Scripting

Perl script variable to read shell command

Solaris 10 Korn shell ksh, Hi there, I have figured out to get yesterday's date which is using the below command: TZ=GMT+24; date +%d-%b-%Y to get the format of 30-Sep-2008 and TZ=GMT+24; date +%Y%m%d to get the format of 20080930. I need this two format. In my perl script below I need... (4 Replies)
Discussion started by: bulkbiz
4 Replies

4. Shell Programming and Scripting

Perl or Shell script to read a transaction log in real time

Hello, I have a Apache webserver running on RedHat. Its primary function is a proxy server for users accessing the internet. I have a transaction log that logs every transactions of every users. For users trying to access certain sites/content the transactions goes into a 302 redirect loop and... (2 Replies)
Discussion started by: bruno406
2 Replies

5. Shell Programming and Scripting

need shell or Perl script to read multiple input

I need shell 0r Perl script to read multiple input and do something and come out example: echo “ enter the host names separated by space “ read servers foreach @servers { do do something done} Here host names like host1 host2 host3 . . . . . . . so on Please help me... (8 Replies)
Discussion started by: sreedhargouda
8 Replies

6. Shell Programming and Scripting

Script to read email from Esxchange OWA server

Hi all. I was asked to monitor our email process end to end, so that we can track that email is being delivered and the delay if any. The email system I am monitoring is a Microsoft exchange with the built in Microsoft Web front end. The monitoring systen is Nagios running on CentOS. I... (3 Replies)
Discussion started by: salatconed
3 Replies

7. Shell Programming and Scripting

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each certificate and send the mail to the user. The user takes action to add the new certificate to the storage file and user owns the responsibility to update the input text file with the new certificate... (5 Replies)
Discussion started by: casmo
5 Replies

8. Shell Programming and Scripting

Mailx, Table, Multiple Email script

Hello, I am able to write some simple scripts in linux but this time it seems a little bit hard for me. Objective: Script will read Database.txt file and will submit separate emails to multiple persons. Database.txt Elvis-Presley user_ssh1 ##20140403 firstperson@gmail.com Julia-Roberts... (3 Replies)
Discussion started by: baris35
3 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. UNIX for Beginners Questions & Answers

Shell Script to read hive table and send email

HI Team, I am working on reading hive table and send email in email body using shell script, can you please help on fixing the errors: I have 6 columns in my hive table and trying to send the email in the mail body. below script: #!/bin/bash hive -e 'SELECT count(*) from db.table' >... (4 Replies)
Discussion started by: Mi4304
4 Replies
MHMAIL(1)                                                            [nmh-1.5]                                                           MHMAIL(1)

NAME
mhmail - send or read mail SYNOPSIS
mhmail [addrs ...] [-body text] [-cc addrs ...] [-from addr] [-subject subject] [-version] [-help] DESCRIPTION
mhmail is intended as a replacement for the standard Berkeley mail program (mail or mailx), which is compatible with nmh. This program is intended for the use of programs such as cron, which expect to send mail automatically to various users. It is also used by various nmh commands to mail various error notifications. Although mhmail can be used interactively, it is recommended that comp and send be used instead to send messages. When invoked without arguments, it simply invokes inc to incorporate new messages from the user's maildrop. When one or more users is specified, a message is read from the standard input and spooled to a temporary file. mhmail then invokes post with the name of the tempo- rary file as its argument to deliver the message to the specified user. The -subject subject switch can be used to specify the "Subject:" field of the message. By default, mhmail will read the message to be sent from the standard input. You can specify the text of the message at the command line with the -body text switch. If the standard input has zero length, mhmail will not send the message. You can use the switch -body "" to force an empty message. Normally, addresses appearing as arguments are put in the "To:" field. If the -cc switch is used, all addresses following it are placed in the "cc:" field. By using -from addr, you can specify the "From:" header of the draft. Naturally, post will fill-in the "Sender:" header correctly. FILES
/usr/bin/mh/inc Program to incorporate maildrop into folder /usr/lib/mh/post Program to deliver a message /tmp/mhmail* Temporary copy of message SEE ALSO
inc(1), post(8) DEFAULTS
None CONTEXT
If inc is invoked, then inc's context changes occur. MH.6.8 11 June 2012 MHMAIL(1)
All times are GMT -4. The time now is 02:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy