The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
sort mail based on subject in unix. sriram.s Shell Programming and Scripting 2 02-02-2007 07:38 AM
search file, change existing value based on input (awk help) nortonloaf Shell Programming and Scripting 3 12-06-2006 01:35 AM
Mail based on file size rajendragora UNIX for Dummies Questions & Answers 2 07-14-2006 07:53 AM
How to grep in order based on the input file Kelam_Magnus Shell Programming and Scripting 2 09-24-2002 03:26 PM
Saving of UNIX based e-mail on to local disks rajan9 UNIX for Advanced & Expert Users 4 08-07-2002 02:49 AM

Closed Thread
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
  #1 (permalink)  
Old 05-13-2008
eagercyber eagercyber is offline VIP Member  
Supporter
  
 

Join Date: Mar 2008
Location: Bangalore
Posts: 14
Script based on input mail

Hi,

I am looking for examples of scripts which monitor for a mail from an id , say abc@xyz.com and if that comes, would reply with the contents of a file. The file is a dynamic status of some automated task.

Also as variations, I would send the a string as the content of the mail. That would executed and o/p would be replied. Ex:- 'df -k .' would get me the disk status.

Any examples are most welcome.

Thanks,
  #2 (permalink)  
Old 05-13-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Sounds like procmail or mailfilter depending on whichever happens to be already installed, or more to your liking. Here's Procmail, for better or for worse:


Code:
# Match on envelope sender line (might not work if your MTA is different from mine)
:0
* ^From abc@xyz\.com\>
{
   # save a copy for archiving / auditing
   :0c:
   fromabc

   # respond with df -k . output
   :0
   | ( formail -r ; df -k . ) | $SENDMAIL -t
}

This is very bare-bones and doesn't do any loop control; you'll find safer, better examples in the procmailex manual page.

Last edited by era; 05-13-2008 at 03:41 AM.. Reason: Comment that match is on envelope From_ line
Closed Thread

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 07:11 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