Adding email to shell scripts

if [[ -s dbverify.out ]];then
cat dbverify.out | mailx -s "DBVerify results for $(uname -n): Errors" '[email protected]'
else
echo "No errors" | mailx -s "DBVerify results for $(uname -n): No errors" '[email protected]'
fi
New to shell scripts, This is script, i want to add few more email addresses , will this work?
'[email protected], [email protected], [email protected]'

Anything not in square brackets [] is required.
Anything in square brackets [] is optional.
Ellipses "..." means any number of the same, like "arg ..." means at least one "arg" but as many more as you need.
A comma-separated list looks like "arg,..." or the "arg", a comma, and then ellipses.
So:
$ man mailx
shows:
mailx [-s subject] address...
which means:
The token "mailx" is required.
The mail subject may optionally be specified using the "-s subject" switch. Note that since only one token "subject" is used for the mail subject, you can use only a single command line token; if your subject needs spaces in it, you must use quotes to make it a single token:
$ mail -s 'This subject has spaces' [email protected]
Now, since the "address..." does not have a common between "address" and the "..." you do not separate the email addresses by commas -- use whitespace.
I know reading man(1) pages takes a bit of getting used to. They are designed as a memory aid, not instructional material. Often you can use the info(1) tool for more details. For example:
$ man make
$ info mailx
give vastly different documentation.
Hope this helps.

Similar Messages

  • Launchd won't send email via shell script

    I'm trying to send an email via shell script. e.g. my shell script is something like this:
    #!/bin/sh
    echo testing | mail -s 'this is a test' [email protected]
    My launchdaemon runs the script: /usr/local/scripts/testscript.sh
    I know the script is working, because I added some debugging (I added a line: echo is this working and sure enough, "is this working" is showing up in the console) but the email part kicks off an error message about 30 seconds later: Stray process with PGID equal to this dead job: PID ### PPID 1 sendmail
    The script works when I run it with a cron job. But why wouldn't it work as a launchd item? And why is it I'm only having problems with the email segment of my scripts? I've tried other scripts and they all seem to work fine.

    There are no errors reported. I'm looking in /var/log/mail.log.

  • How to Email Concurrent Program Output to Email using Shell Script

    Hi All,
    Have a Nice Day,
    I have a tricky requirement and i was not able to achieve, let me explain my requirement
    I have created a PLSQL Concurrent Program named "Approval Update". This will do update and it display the number of rows updated.
    Now i need to take this concurrent program output and it needs to be send it to the person who submits this program as an email using shell scripts.
    I have referred meta link note as well as some OTN posts but I was not able to achieve this.
    Please help me to complete this As soon as possible, Thanks in advance for your help.
    Let me know if you need more clarifications.
    Regards,
    CSK

    I don't have much idea in shell scripts all i want is, in my shell script i need to get the parent concurrent program output and that needs to be emailed to the intended person.
    Please help to to get the shell script commands for this.I do not have any shell script to share, sorry! If you want the query to get the parent request_id so you can get the log/out file name/location from then please refer to:
    REQUESTS.sql Script for Parent/Child Request IDs and Trace File IDs [ID 280295.1]
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONC_REQ_SUMMARY_V&c_owner=APPS&c_type=VIEW
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_REQUESTS&c_owner=APPLSYS&c_type=TABLE -- LOGFILE_NAME & OUTFILE_NAME
    Thanks,
    Hussein

  • Sending an email using shell script in Oracle Applications

    Hi,
    I have a pl/sql package which will call a shell script program.The shell script program is written in order to send the invoice hold details of AP as a mail.The parameters to this program are passed in the pl/sql package.
    The shell script program has
    5 parameters namely
    to - email
    from - email
    hold id - which is a number
    hold name - varchar2( free text)
    hold reason - varchar2( free text)
    the shell script looks as below.
    FROM_EMAIL=`echo $1|cut -f9 -d " "|sed 's/\"//g'`
    echo "From email id is $FROM_EMAIL" -- From email
    TO_EMAIL=`echo $1|cut -f10 -d " "|sed 's/\"//g'`
    echo "To Email id is $TO_EMAIL" -- to email
    PARAM0=`echo $1 | awk '{print $11}'|sed -e "s/\"//g"`
    echo "Param0: $PARAM0" -- hold id
    PARAM1=`echo "$1" | cut -d" " -f12-| sed -e "s/\" \"/\"^\"/g" | awk -F'^' '{print $1}'|sed -e "s/\"//g"`
    echo "Param1: $PARAM1" -- hold name
    PARAM2=`echo "$1" | cut -d" " -f13-| sed -e "s/\" \"/\"^\"/g" | awk -F'^' '{print $1}'|sed -e "s/\"//g"`
    echo "Param2: $PARAM2" -- hold reason
    the values that am passinf to this program are if suppose
    from email ---- [email protected]
    to email [email protected]
    12345 ------ hold id
    test hold name ------ hold name
    test hold reason ------- hold reason

    Is there a question here?
    In any case you could easily have done this inside the database using UTL_SMTP.

  • Can't enter shell scripts in Automator?

    When adding the "Run Shell Script" action to a workflow in Automator, I can't actually type anything in the text box -- when I try to type something, I just get a bunch of seemingly random characters. Does anyone else see the same behaviour or is there just something funky going on with my two Macs?
    I'm certain I'd be able to create a couple of services for encrypting/decrypting messages in Mail with GPG, if only I could actually type the shell script into Automator

    Redemption Code http://helpx.adobe.com/x-productkb/global/redemption-code-help.html

  • Sending email attachments using unix shell script

    hi
    I want to send report generated my spooled file as attachment using unix shell script.
    Can somebody help me out ?
    many thanks

    thanks a tonn it worked.
    but i have another issue is it possible to add names in CC also ?
    Also here is my code which spools the output of SP to a txt file. the File name is generated dynamically.
    as shown below:
    I need to send this generated file as attachement.
    how do I do this? Here the shell script
    =========================================================
    #!/bin/sh
    ORA_USER=scott
    ORA_PWD=tiger
    #Get the input parameter
    if [ ! "$1" ]; then
    STR="NULL"
    else
    STR="'"$1"'"
    fi
    #echo "exec pkg1($STR);"
    #Connecting to oracle
    sqlplus -s <<EOF
    $ORA_USER/$[email protected]
    ---sql plus enviornment settings
    set linesize 160
    set pagesize 60
    set serveroutput on size 1000000 for wra
    set feedback off
    set termout off
    column dcol new_value mydate noprint
    select to_char(sysdate,'YYYYMMDDHH24MISS') dcol from dual;
    spool &mydate.report.txt
    exec pkg1($STR);
    spool off
    EOF
    exit
    =========================================================
    the file name will take sysdate as name so that every time a new file will be generated.
    this file I need to send as attachment.
    null

  • Shell Script to send email with .txt file as attachment

    Dear Al,
    Could any one help me with code, for sending email with .txt file as attachment using shell script.
    Thank You!

    978334 wrote:
    Dear Al,
    Could any one help me with code, for sending email with .txt file as attachment using shell script.
    Thank You!http://bit.ly/XHfSCz
    https://forums.oracle.com/forums/search.jspa?threadID=&q=sendmail&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • EMail Address Validation - Shell Script

    Hi,
    I have a custom concurrent program (Shell Script Program). One of the input parameter is Email address.
    In my code, I need to validate email address format (Ex: [email protected])
    Can anyone paste the code snippet.
    I have tried with the below validation
    case $EMAIL_ID in
         *@?*.?*) echo "Email Address Validated.";;
         *) echo "Invalid Email Address. Please enter the correct format of email address and re-run the program";
    exit 1;;
    esac
    This validation is failing in this scenario xxx,[email protected] / xxx [email protected] (If user enters the email address with comma or a blank space. This validation is returning success message)
    Regards
    BS

    Please look up the syntax for this by typing
    man mailx
    on the shell command prompt.
    Please stop asking Unix specific questions in an Oracle forum. There are more than enough Unix forums on the Internet.
    Please refrain from asking further doc questions here.
    You are in gross violation of the 'Forums Etiquette' post.
    Sybrand Bakker
    Senior Oracle DBA

  • [SOLVED] Getting a Shell Script to Email Me

    Hello everyone, I'm playing around with shell scripts trying to get the hang of getting them to email me. I'm playing around with this on my laptop, eventually I am going to try to have my server automate some tasks using cron and email me the status. As an experiment I'm just trying to get something simple like a list of packages emailed to myself. I googled around to come up with this script. I also installed postfix and set up the daemon to run. Here is my test script:
    #!/bin/bash
    # script to send simple email
    pacman -Qe > /tmp/packages.txt
    # email subject
    SUBJECT="Test subject"
    # Email To ?
    EMAIL="my.email.address"
    # Email text/message
    EMAILMESSAGE="/tmp/packages.txt"
    echo "This is an email message test"> $EMAILMESSAGE
    echo "This is email text" >>$EMAILMESSAGE
    # send an email using /bin/mail
    mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
    rm /tmp/packages.txt
    However, I don't receive an email.
    Note: I withheld my email address above so I don't get spam, but it is in the script.
    Last edited by jlacroix (2011-04-11 17:43:01)

    discon wrote:I personally use "sendEmail" (http://aur.archlinux.org/packages.php?ID=7335) so I don't have to setup postfix etc. You may want to try with that to determine if it's a problem with your script or with your postfix installation.
    Thank you for that! I installed it and reviewed the documentation and was successful. If it helps anyone else, here is the code I used (after installing the package) to send myself an email of installed packages, which I can surely use to send myself any report I want:
    #!/bin/bash
    pacman -Qe > /tmp/packages.txt
    sendEmail -f [email protected] -t smtpusername -u Installed Packages on Computer Name -m These packages are currently installed: -a /tmp/packages.txt -s smtp.server.net:25 -xu smtpusername -xp smtppassword
    rm /tmp/packages.txt

  • Shell scripts to to moniter applications status and email.

    I want to create a script in Linux to moniter applications running or not ,if not send an email with details and logs.
    I am new to shell scripts. Appreciate your help.

    Hi,
    This forum is for Microsoft technologies. You'll get better Linux help in Linux focused forums, such as this one:
    http://www.unix.com/shell-programming-and-scripting/
    Good luck.
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • Problem while passing parameter to shell script which sends email-Ora Apps

    Hi,
    I have a pl/sql package which will call a shell script program.The shell script program is written in order to send the invoice hold details of AP as a mail.The parameters to this program are passed in the pl/sql package.
    The shell script program has
    5 parameters namely
    to - email
    from - email
    hold id - which is a number
    hold name - varchar2( free text)
    hold reason - varchar2( free text)
    the shell script looks as below.
    FROM_EMAIL=`echo $1|cut -f9 -d " "|sed 's/\"//g'`
    echo "From email id is $FROM_EMAIL" -- From email
    TO_EMAIL=`echo $1|cut -f10 -d " "|sed 's/\"//g'`
    echo "To Email id is $TO_EMAIL" -- to email
    PARAM0=`echo $1 | awk '{print $11}'|sed -e "s/\"//g"`
    echo "Param0: $PARAM0" -- hold id
    PARAM1=`echo "$1" | cut -d" " -f12-| sed -e "s/\" \"/\"^\"/g" | awk -F'^' '{print $1}'|sed -e "s/\"//g"`
    echo "Param1: $PARAM1" -- hold name
    PARAM2=`echo "$1" | cut -d" " -f13-| sed -e "s/\" \"/\"^\"/g" | awk -F'^' '{print $1}'|sed -e "s/\"//g"`
    echo "Param2: $PARAM2" -- hold reason
    the values that am passinf to this program are if suppose
    from email ---- [email protected]
    to email [email protected]
    12345 ------ hold id
    test hold name ------ hold name
    test hold reason ------- hold reason
    The output for the above parameters is as follows
    from email ---- [email protected]
    to email [email protected]
    12345 ------ hold id
    test hold name ------ hold name
    hold name --------hold reason (a part of hold name parameter is displayed as hold reason.The reason being in param2 we used cut which is cutting from 13.
    the problem here is since param1 being free text we cannot predict at what position the parameter ends.i mean there might be a single word or more than 2 words in that parameter seperated by space. the question here is ... is there anyway that we can specify dynamically from which location the param2 should fetch the value.
    can we use some delimiter to identify the end of param1 and start of param2.If so... how can it be written in this scenario.
    Thanks in Advance.

    As I see, all parameters are merged into 1 at shell script.
    Please do as follow:
    1- Modify your shell script as followed:
    echo "From email id is $1" -- From email
    echo "To Email id is $2" -- to email
    echo "Param0: $3" -- hold id
    echo "Param1: $4" -- hold name
    echo "Param2: $5" -- hold reason
    2- rename your shell script file with .prog extension : CUSTOM_NAME.prog
    3- perform the following command at custom file location:
    ln -s $FND_TOP/bin/fndcpesr CUSTOM_NAME
    This approach will seperate your parameters and then it will be more easier to manipulate them.
    Regards

  • Shell script to send concurrent program output via FTP and Email

    Hi,
    Does any one have a shell script to send the output generated by a concurrent proram
    1 - Using FTP to an external server
    2 - By email as an attachment.
    Thanks

    There are more specific forums which address this question within the Oracle Technology Network. Please consider posting your question there for better responses. The focus of this forum is limited to HRMS suite of modules:
    http://forums.oracle.com/forums/categoryHome.jspa?categoryID=84
    Regards,
    Greg

  • How to send an mail to my email by using shell scripting

    Hi,
    I have shell script which generates some text file with text information. Now i want to send over the information available in the text file to my mail id.
    Can anyone give me over the syntax or the script.?
    Thanks a lot
    With Regards
    Vedavathi E

    same typo
    should read
    mailx -s 'subject for mail message ' your_email_address < text_file_to_be_sent
    Guido

  • Sending email using bash script

    Hello:
    I am working on writing a bash script to notify one or more users by email of certain events. Run from the Terminal command line, and having the script "echo" text of (what would be) a form letter with in-line variable expansion (i.e., ${VARIABLE}), all seems to work as anticipated. Eventually, I want cron to launch this shell script, and send an email to an "on-subnet" user (I have postfix enabled on my Mac, and there are multiple local user accounts).
    I found some stuff on the web about sending mail from bash scripts, and so I made a small little test script, that reads like this:
    #!/bin/bash
    VARIABLE[1]="The 12,345 quick brown foxes "
    VARIABLE[2]="jumped over the 67,890 lazy dogs."
    mail -s "a test email" jv << EOF
    This is a test:
    ${VARIABLE[1]}
    ${VARIABLE[2]}
    This is the last line of the test message.
    EOF
    echo "script completed"
    It worked... almost... It sent a local email to my postfix mail account that read like this:
    This is a test:
    The 12,345 quick brown foxes
    jumped over the 67,890 lazy dogs.
    This is the last line of the test message.
    EOF
    echo "script completed"
    So, I have two questions. First, the easy one (I hope):
    How do I delimit the end of the text, that I want to be the message body of the email, from portions of the script that follow said email text?
    Next question is a little more involved. You know how, in Mail.app, if you go to Mail Preferences>Accounts>Account Information, you can put multiple email addresses, comma-delimited, in the "Email Address" field? So, if a person entered "[email protected], [email protected], [email protected]" in this field, then, even though (s)he may be at home, and using their home ISP's mail server, (s)he could send an email apparently from either their home, work, or school email address. Of course, the mail headers clearly would show it came from and through their home machine and home ISP, but it would be displayed in the recipient's Mail client viewer as having come from one of [email protected], [email protected], or [email protected].
    I'd like to do something similar here, whereby the email (that is being sent to one or more local users' postfix account on my computer) would apparently be sent from "watchdog@localhost" rather than from "jv@localhost" like it seems to do by default. Whatever account the script is run from (or presumbably, whose cron tab is launching the script) is what the "From" address is set to.
    I'd rather not create an additional mail account, because I am using Mac OS X built-in accounts for the postfix mailboxes (I don't want to have to maintain a plaintext username:password file in postfix, and I don't want to create an additional user account on the computer).
    So, is there a way to specify an alternate "From" username when invoking the mail -s ${SUBJECT} ${RECIPIENT} command in a bash script? Or is there a different, alternate mail command that will let me do so? (please include a description of syntax and how I'd package the above message text for the alternate method).
    Thanks in advance, all!

    Hi j.v.,
    The > after EOF is just a typo (or may be added by the Discussion ?) and you must delete it; other > are prompts from the interactive shell. Andy's post shows an interactive use of shell, not a shell script (note the shell prompt % in front of the commands). A typical use of here document may look like
    command <<ENDOFDATA
    ENDOFDATA
    There must be no spaces before and after ENDOFDATA. The word ENDOFDATA can be EOF or any other string which is guaranteed not to appear in the text (the .... in the example above).
    You can modify the From: header by using sendmail command (postfix has it as a compatibility interface):
    /usr/sbin/sendmail -t <<EndOfMessage
    Subject: test mail
    To: jv
    From: watchdog
    This is a test:
    ${VARIABLE[1]}
    ${VARIABLE[2]}
    This is the last line of the test message.
    EndOfMessage
    There must be a blank line between the headers and the mail body.
    I assume that you send these mails only to users on your local Mac. Please do not send mails to remote users by using the sendmail command unless you know what you are doing completely.
    PowerMac G4   Mac OS X (10.4.5)  

  • How to submit request(Report+Template) using Shell Scripts?

    Hi Friends,
    How to submit request + Add layout using shell scripts..
    If anybody has sample code..Can you please send me to [email protected]
    Please help me..
    Its Urgent.
    Thanks and Regards,
    A Swain
    Message was edited by:
    SwainA

    Following is a package where the request is submitted and the layout is added.
    Also check iin the other way by adding the layout first n then giving the request.
    CREATE OR REPLACE PACKAGE BODY try
    AS
    PROCEDURE try_proc
    errbuf OUT VARCHAR2,
    retcode OUT NUMBER
    IS
    l_mode BOOLEAN;
    l_request_id NUMBER;
    xml_layout BOOLEAN;
    BEGIN
    fnd_file.put_line (fnd_file.output, 'USER_ID :' || fnd_global.user_id);
    fnd_file.put_line (fnd_file.output, 'REQU_ID :' || fnd_global.resp_id);
    fnd_file.put_line (fnd_file.output,
    'RESP_APPL_ID :' || fnd_global.resp_appl_id
    l_mode := fnd_request.set_mode (db_trigger => TRUE);
    IF l_mode IS NOT NULL
    THEN
    fnd_file.put_line (fnd_file.output,
    'Concurrent MODE Option is Success'
    END IF;
    -- if wrong paramters error recd give all 100 arguments as null
    l_request_id :=
    fnd_request.submit_request (application => 'app_short_name',
    program => 'shortname',
    sub_request => FALSE
    fnd_file.put_line (fnd_file.output,
    'Request_Id 1 is :' || l_request_id
    xml_layout :=
    fnd_request.add_layout (template_appl_name => 'SQLAP',
    template_code => 'CAPINEF01',
    template_language => 'en',
    template_territory => 'US',
    output_format => 'PDF'
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN
    fnd_file.put_line (fnd_file.LOG,
    'Error in procedure package procedure :'
    || SUBSTR (SQLCODE, 1, 20)
    || ':'
    || SUBSTR (SQLERRM, 1, 250)
    END try_proc;
    END try;

Maybe you are looking for