Link to home
Start Free TrialLog in
Avatar of loriwang7310
loriwang7310

asked on

need to auto-read mail

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
Avatar of ahoffmann
ahoffmann
Flag of Germany image

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

# is this what you mean?
Avatar of loriwang7310
loriwang7310

ASKER

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
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).
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
ASKER CERTIFIED SOLUTION
Avatar of chris_calabrese
chris_calabrese

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.


the simplest way is procmail, IMHO ...
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


Good luck.