shell将发送输出作为附件发送到电子邮件

时间:2015-03-30 17:02:31

标签: linux shell

我不知道这个脚本有什么问题。我没有收到任何错误,我也没有收到此电子邮件。

代码:

    #!/bin/ksh

    # -----------------------------------------------------------------------
    # Filename:   mailx.ksh
    # Purpose:    Demonstrates how one can attach files when sending E-Mail
    #             messages from the Unix mailx utility.
    # Author:     Frank Naude, Oracle FAQ
    # -----------------------------------------------------------------------

    SUBJECT="Send mail from Unix with file attachments"
    TO=abcd@gmail.com
    SPOOLFILE=/home/abcd/test_mail/sqlplus_test.txt

- sql part ---

    echo "Produce listing from SQL*Plus..."
    sqlplus -s abcd/xxxxx >$SPOOLFILE <<-EOF
            set echo off feed off veri off pages 0 head off
            select count(*) from abcd;
            exit;
            EOF

- 发送带附件的电子邮件

    echo -e "This email has a attachments" | mutt -a "${SPOOLFILE}" -s "This is a test email with attachment" -- abcd@gmail.com <<-EOF

            Hi,

            This sample E-mail message demonstrates how one can attach
            files when sending messages with the Unix mailx utility.


            Best regards

            ~.
            EOF

0 个答案:

没有答案