Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003
    Posts
    369

    Unanswered: email notification in DB2 script

    I wrote a script that does file transfer of DB2 table data as part off failover processing. Does anyone know how I can add email notification to be sent to the operator email for example after the script runs and whether the process succeeds or fails? Here is the sample script:

    db2 connect to proddb;

    db2 "EXPORT TO /stage1/export/oltptable.del OF DEL MESSAGES export.txt SELECT * FROM OLTPTABLE";

    HOST='MYHOST.COM';
    USER='db2inst1';
    PASSWD='PASS';
    #

    FILES='/stage1/export/oltp.del';

    for FILE in $FILES
    do
    ftp -n $HOST <<END_SCRIPT
    quote USER $USER
    quote PASS $PASSWD
    prompt
    cd /stage1/export
    put $FILE
    quit
    END_SCRIPT
    echo "Processed " $FILE
    done
    exit 0

    # Output results of FTP processing files email operator@mywork.com;
    # telnet myserver.com, login to server; cd /stage1/export;
    # ls -ls>files.txt; mail files.txt operator@work.com

    Sorry havent written extensive scripts in a while

    Scott

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: email notification in DB2 script

    Originally posted by mixxalot
    I wrote a script that does file transfer of DB2 table data as part off failover processing. Does anyone know how I can add email notification to be sent to the operator email for example after the script runs and whether the process succeeds or fails? Here is the sample script:

    db2 connect to proddb;

    db2 "EXPORT TO /stage1/export/oltptable.del OF DEL MESSAGES export.txt SELECT * FROM OLTPTABLE";

    HOST='MYHOST.COM';
    USER='db2inst1';
    PASSWD='PASS';
    #

    FILES='/stage1/export/oltp.del';

    for FILE in $FILES
    do
    ftp -n $HOST <<END_SCRIPT
    quote USER $USER
    quote PASS $PASSWD
    prompt
    cd /stage1/export
    put $FILE
    quit
    END_SCRIPT
    echo "Processed " $FILE
    done
    exit 0

    # Output results of FTP processing files email operator@mywork.com;
    # telnet myserver.com, login to server; cd /stage1/export;
    # ls -ls>files.txt; mail files.txt operator@work.com


    Sorry havent written extensive scripts in a while

    Scott
    Collect the output of your script into a file (eg /tmp/ftp.log) and then:

    cat /tmp/ftp.log | mailx -s "FTP results" operator@work.com
    ---
    "It does not work" is not a valid problem statement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •