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

Posted on 2006-03-29
Last Modified: 2013-12-27
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.      

Question by:LindaC
    LVL 10

    Expert Comment

    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.
    LVL 6

    Expert Comment

    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.

    LVL 76

    Expert Comment

    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.
    LVL 8

    Author Comment

    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.
    LVL 76

    Expert Comment

    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?
    LVL 8

    Author Comment

    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
    LVL 76

    Expert Comment

    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.

    LVL 8

    Author Comment

    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
    LVL 8

    Author Comment

    As I said before I run the test cat exp_db_scoredev.log | mailx  -s  "Test" <>  but I did not receive any mail.
    LVL 10

    Accepted Solution

    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.
    LVL 7

    Expert Comment

    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

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
    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…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

    746 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

    17 Experts available now in Live!

    Get 1:1 Help Now