Solved

need to auto-read mail

Posted on 2002-07-26
9
330 Views
Last Modified: 2010-04-21
I have a file on computerA that
I want to mail to another computerB.
I need some code to put on B to
automatically read the mail message
from A and write that message to a file.

I need script to run mailx or some other
mail program out of crontab at the time
the mail message is expected or loop
until it gets there.  And then look for
that particular subject to get the right
one and write that one to a file on computer
B.  I think people do this with subscribe/
unsubscribe but I don't know where to look.

Help?

-----Lori
0
Comment
Question by:loriwang7310
  • 4
  • 3
  • 2
9 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7181143
# on computerA
  rsh computerB cat file '|' mailx -ssubject user@computerA
  rsh computerB grep ^Subject: file '|' mailx -ssubject user@computerA

# is this what you mean?
0
 

Author Comment

by:loriwang7310
ID: 7185033
ahoffman,

Nope, they have disabled rsh and rhosts and every
thing else that lets computers see each others files.

I can mail from A to B, no problem.  What I need to
do is read mail on B from a script.  The script needs
to run by itself out of cron or at and try to pick out
that particular mail message that A sent.

I don't know the batch commands to mailx or sendmail
that would do that.

-----Lori
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 7185562
Assuming both systems are Unix, you'd put in a .forward file on system B that pipes all the mail to the account to a script that pulls out the "interesting" messages (see the man page for 'sendmail' on your system for how to do this).

You might also want to use 'procmail' instead of writing your own script (free tool you can get from the 'net).
0
 

Author Comment

by:loriwang7310
ID: 7185779
Chris,

Nope, don't need .forward, I can get the
message to B, no problem.  I don't see
what .forward would do for me.  I get
the message fine.  They are probably not
gonna let me install procmail, they
won't even let me pass files around,
I'm forced to mail them.

I just need to know what are the sendmail
commands to pull out a message by its
subject header, in a script, in batch mode?
I've looked at the sendmail and mailx man
pages and I'm not seeing it.



-----Lori
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Accepted Solution

by:
chris_calabrese earned 100 total points
ID: 7185861
There aren't any. The way you do it is to setup a .forward file to pass all the mail through a script. This script then parses the mails and pulls out the ones it's interested in, sticking the rest in the user's mailbox. See the 'sendmail' man page on your system for deatils.

As for installing procmail, you don't need the system admins's to install it, but rather can simply run it from your home directory or some such.

MEANWHILE, did you bother asking the system administrators what they though the right way to do this was? If they've turned off the r* protocols, it's probably for security purposes. But then, perhaps they run SSH (secure replacement for the r* services) and you can SCP the data, or something like that.
0
 

Author Comment

by:loriwang7310
ID: 7185986
Nope, I checked the forward man page and I
see how to forward it to a script but I still
need the commands in the script to pull out
the message body.  Procmail looks way too
powerfull for what I want to do.  I've asked
the sys.admin about scp but they don't know
what it is and there's no man page out there
on it.  I guess I might give up and just read
the /var/spool/mail file.  but just thought
there was some easy way to do this with a
script.


0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7186220
the simplest way is procmail, IMHO ...
0
 

Author Comment

by:loriwang7310
ID: 7190352
Chris,

I figured out what you were talking about
with the .forward file.  So as a first
baby step I have that writing the whole
mail message (and I guess every message)
to a disk file on computer B.

I will have to work on writing a filter
to pull out the actual data records I'm
looking for, may take me some time.

Thanks for your help and ahoffman's help.
I appreciate it!

-----Lori


0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 7191129
Good luck.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Vmware Vswitch  VS  Redhat  Bridge 1 100
Shell script errors 10 115
how to monitor remote shell execution on linux 9 97
Access_log 17 101
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now