Script in the server is sending mail to the oracle@<servername.domain> instead of the list of persons in the script

We have lotus Notes in the company and ther diferent unix and solaris servers send through this Lotus Notes Mail server to the emails we want.
I have the following script and it is running, but it is sending an email to himself in Lotus Notes and the Lotus Notes Administrator told me to check the script:

export HOME
export PATH
NLS_LANG=American_America.WE8ISO8859P1;export NLS_LANG
cat /home/app/dba/exports/exp_pipe.dmp | compress > /home/app/dba/exports/scored
ev.dmp.Z &
exp backup_user/backup_user file=/home/app/dba/exports/exp_pipe.dmp compress=y f
ull=y statistics=none log=/home/app/dba/logs/exp_db_scoredev.log
#dsmc incremental /home/app/dba/exports/scoredev.dmp.Z
cd /home/app/dba/logs
egrep "ORA-|rejected|Killed|EXP-" $log >/dev/null 2>&1 && cat $log | mailx -s "S
COREDEV export with error" <person#1>@<>  <person#2>@<> <person #3>@<> <person #4>@<> <person#5>@<>


The email sent is this:

Oracle Account <>
03/29/2006 02:11 AM      

Output from "cron" command

And the body is the export log.      

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

That's means the mailx command in your script is never executed - so something is up with the line:

egrep "ORA-|rejected|Killed|EXP-" $log >/dev/null 2>&1 && cat $log | mailx -s "SCOREDEV export with error" <person#1>@<>  <person#2>@<> <person #3>@<> <person #4>@<> <person#5>@<> <person#6>@<>

If a crontab job throws any STDOUT or STDERR output, cron will automatically send the user that owns the jobs an email showing the output with a SUBJECT line exactly as you're shown.  So cron is doing exactly what its supposed to do.  It apparently looks that the logic in your script that isn't working.  The logic looks like it should work.

You might try changing it to look like this:

egrep -s "ORA-|rejected|Killed|EXP-" $log && cat $log | mailx -s "SCOREDEV export with error" <person#1>@<>  <person#2>@<> <person #3>@<> <person #4>@<> <person#5>@<> <person#6>@<>

and see if this changes the behavior at all.
Try editing /etc/mail/aliases and add an alias in that file for Oracle that points to a real email address.

Another tack is to export a var that replaces all the email addresses. e.g.
>export ORACLE_SID
export MAILMEN=<person#1>@<>,<person#2>@<>,<person #3>@<>,<person #4>@<>,<person#5>@<>

egrep "ORA-|rejected|Killed|EXP-" $log >/dev/null 2>&1 && cat $log | mailx -s "S
COREDEV export with error" $MAILMEN

I assume you already have your mailhost/mail server listed in /etc/hosts.

Still another tack is to have a Distribution List in Lotus Notes as an alias to the oracle user - I find it interesting that the mail server has an "oracle" user account.

If you have sendmail, postfix, qmail, exim installed on the local system, you might be better off using those instead of an email client like mailx (X-window) or mail to send messages out.
The script to do that is fairly simple.

ie. you build up the header and the body of the message.
messages="To: <someemailaddress>
From: <someemailaddress>
Subject: Somesubject

echo $message | sendmail -oi -fenvelope_sender_email -t

The system reference to sendmail is often consistent but would use the mail app installed on the system.

This provides you more control on formating and content of the email and does not involve and indermediery email client that might not do what you expect.
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

LindaCAuthor Commented:
Nukfor - I changed the script to your suggestion yesterday, but today I receive another "friendly email" from our System Administrator telling me that again they receive in the Lotus Notes a mail to oracle@scoredevdb...

Arnold, we don't have sendmail because I  don't see a /etc/default/sendmail file anywhere there.

bpeterse:  We do have the entry to the mail in the /etc/hosts, that is why the System Adminsitrator email me telling me that in Lotus Notes they receive the mail from oracle@scoredevdb.. sititing there in Lotus Notes because it pointed to nobody.

I don't know why it is not functioning in this particular server because in all 100...other servers it is functioning well both solaris and unix.
There is something not quite well here and I count with one of you to find the hidden so much tresured answer to this puzzle.
sendmail is just the common reference.

what does mailx/mail use to inject the email into a queue on the local system?

Is the script running in the same shell as on the servers where it does work.

If you are logged in on this server, and perform a similar
cat message | mailx  with the same parameters
what happens?
LindaCAuthor Commented:
Arnold:  I'am an oracle dba I am not a System Administrator.  So I do not understand the question:  what does mailx/mail use to inject the email into a queue on the local system?.  Please give me specific instructions that I can type in the solaris box.

About the Shell:

In socredevdb where the sending of the mail to oraacle@scoredev to Lotus Notes occurs even though there is no errors in the log:

oracle:x:100:100:Oracle Account:/home/app:/bin/ksh

In scoreproddb where the sending of the mail to oracle@scoreproddb does not occur:

oracle:x:10001:102:Oracle Account:/export/home/oracle:/sbin/sh

About the test in the scoredevdb server, I went to the export log and type the following command as you instructed but I have not received any mail

cat exp_db_scoredev.log | mailx  -s  <>

When I go to /var/mail the log for the oracle user is not there, see:

scoredevdb(oracle)#cd /var/mail
scoredevdb(oracle)#ls -lt
total 22290
-rw-rw----   1 root     mail     11395321 Feb 26 18:00 root
drwxrwxr-x   2 root     mail         512 Apr 14  2005 :saved
do you have a .forward file in your home dir?
see if you have a /var/log/maillog

If I am not mistaken, you need to designate the receipients of the email on the command line.

LindaCAuthor Commented:
arnold, first I tried again to execute the line   cat exp_db_scoredev.log | mailx  -s  "Test" <>,  second, in the /var/log/   there is a syslog but not a maillog, which has a lot of this lines:

Apr  4 08:21:30 scoredevdb sendmail[23548]: [ID 801593] k316Adjt001073
: to=<>, delay=3+06:10:51, xdelay=00:07:30, mail
er=relay, pri=28008855, [], dsn=4.0.0, stat=Defer
red: Connection timed out with
Apr  4 08:21:31 scoredevdb sendmail[23592]: [ID 801593] k326EEjt008057
: to=<>, delay=2+06:07:17, xdelay=00:07:29, mail
er=relay, pri=19368854, [], dsn=4.0.0, stat=Defer
red: Connection timed out with
Apr  4 08:21:32 scoredevdb sendmail[23632]: [ID 801593] k32Luvjt012482
: to=<>, delay=1+14:24:35, xdelay=00:07:29, mail
er=relay, pri=13878854, [], dsn=4.0.0, stat=Defer
red: Connection timed out with
Apr  4 08:21:34 scoredevdb sendmail[23839]: [ID 801593] k346DQjt021889
: to=<>, delay=06:08:08, xdelay=00:07:29, mailer
=relay, pri=2358854, [], dsn=4.0.0, stat=Deferred
: Connection timed out with
LindaCAuthor Commented:
As I said before I run the test cat exp_db_scoredev.log | mailx  -s  "Test" <>  but I did not receive any mail.
The messages you are seeing indicate sendmail can't talk to for some reason so you won't be getting any email from this system assumign the email is going outbound.  You need to figure out why you're getting the timeouts.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: Nukfror

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.