Getting the email intot he script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting the email intot he script
# 1  
Old 09-07-2008
Getting the email into the script

Hi,

I'm trying to write a simple script to take an email subject line and add it to a db. I've currently given up on getting procmail to work with my hosting folks so that leaves me with a shell script as the next option. I can set things up so when I receive an email the script is triggered, but I can't figure out how to access the email within the script. I tried:

echo $1 $2 $3 $4 $5 $6 $7 $8 $9 > test.log

and:

echo "$1 $2 $3 $4 $5 $6 $7 $8 $9" > test.log

This was based on the assumption that when I set up the filter in my email configuration program, the email would somehow be passed as a parameter. (I'm using Pair hosting service, fwiw).

Any ideas?

Mike

Last edited by mmesford; 09-07-2008 at 06:23 PM..
# 2  
Old 09-08-2008
It's not at all clear how the script is receiving the email, and what you want to accomplish with the echo. How is this script being invoked? (Why isn't Procmail an option?))

For what it's worth, echo "$@" echos however many arguments there are, with spacing intact.

If you are using some sort of .forward then it will be likely be receiving the email as standard input, not as command-line arguments. (The cat command copies standard input to standard output, or you might want to use tee.)

Last edited by era; 09-08-2008 at 04:47 AM.. Reason: Maybe use cat or tee
# 3  
Old 09-08-2008
Hi era, thanks for the reponse. It's not clear to me either how the script receives the email but your stdin tip is probably the key. I'll explore that. As for the rest, I may have figured out the procmail issue so this could all be moot. And the echo was just for testing. Ultimately I want any emails sent to this particular box have their content parsed and added to a mySql db. A long way down the road!

Mike
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need little script to send out email

Hi Scripters, good day. bash-4.2# df -g /apps/prd Filesystem GB blocks Free %Used Iused %Iused Mounted on /dev/xxx 64.00 4.35 94% 1269284 8% /xxx bash-4.2# I was wondering if there is a script when the usage of the mountpoint above hit 98%, email would be... (3 Replies)
Discussion started by: jaapar
3 Replies

2. Shell Programming and Scripting

Simple Email Script

Hi All, Im completely new to scripting but I was wondering can somebody show me how to write a bash script so that if any file enters a specific directory that an email gets sent? I am running a few backups on a few different machines and rysncing them to a remote device, For each server I... (5 Replies)
Discussion started by: jgalvin
5 Replies

3. Shell Programming and Scripting

Email not being sent from shell script

Hi All, I have prepared the below shell script but no email is being sent from the shell script.Not sure what's wrong here: echo $SHELL /bin/bash . $HOME/.profile . /home/oracle/Oracle_xyz.env export log=/orabin/Oracle/rman_Oracle_arch.out rman target /... (4 Replies)
Discussion started by: a1_win
4 Replies

4. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

5. Shell Programming and Scripting

Getting Email from script

I am running a script from crontab and sending the output to another file. This is the statement in crontab: 45 23 * * * /dst/nikutst/clarity/lib/DSTRestartTest1.sh >> /dst/nikutst/clarity/logs/RestartTest.log The script runs fine and sends output to the log file. But I always get a system... (3 Replies)
Discussion started by: snturner
3 Replies

6. Shell Programming and Scripting

Caller Script should produce and email from 4 different script within it

Hi I wrote a shell script , which includes one output file which is emailed back to me , when the script runs . Now i want to slip the script into 4 different shell scripts each of which taking the parameter PROD or DEV, and include all the 4 different shell scripts in a caller script. ... (3 Replies)
Discussion started by: rxg
3 Replies

7. Shell Programming and Scripting

Email through Script

I have a script to sent email when error occur in the process. The scripts use a config file where I dot . ./config.cfg into the environment. However, when I export the message below into the environment and echo $msg, it shows only "THERE" the first word in the sentence. export msg=THERE WERE... (2 Replies)
Discussion started by: rkumar28
2 Replies

8. Programming

email extract script

i want to extract the field from, subject and email body part from an inbox on linux redhat 7.x. prefer perl script or any unix utilities script. please help. :confused: (1 Reply)
Discussion started by: gxiong
1 Replies

9. UNIX for Advanced & Expert Users

route email to a script.

Issue: when i send an email to edi@qgatu001.con-way.com it is supposed to get sent to the deliveryagent es_mime_in so it can get proccessed. ok i got this to happen 1x. Will update over the weekend when i can test to let you know if it works completely. sendmail: 8.12.10. sendmail.mc was... (2 Replies)
Discussion started by: Optimus_P
2 Replies

10. Shell Programming and Scripting

Email alert script

I need to code a script, which will run via cron, every 30 minutes. The script will read a file containing a date&time and number (which represents disk space). The file gets appended to every 30 minutes. Here's a sample of the file: CPU 1:04/25/02 1:00 am:1972554 CPU 1:04/25/02 1:30... (1 Reply)
Discussion started by: moon
1 Replies
Login or Register to Ask a Question