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

Similar Messages

  • Sending email attachements using unix !!

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

    Nothing to do with PL/SQL.
    Anyway, here's a snippet from a Unix shell script I wrote that does notification (via various methods). The code snippet is from the part where an e-mail with attachment is created for the Unix mail command. The variable names are (I hope) self explanatory.
    <font color="blue">
    ConstructMail()
      # do we have an attachment and does the file exist?
      if  [ "$ATTACHMENT" != "" ] && [ ! -f $ATTACHMENT ]
      then
        Abort "Error. File [$ATTACHMENT] not found."
      fi
      # create the boundary tags for the attachment
      if [ "$ATTACHMENT" != "" ]
      then
        BASE=`basename ${ATTACHMENT}`
        BOUNDS1="-"`hostname`.`date +%y%m%d%H%M`.$$
        BOUNDS2="--"$BOUNDS1
      fi
      # now we construct a MIME e-mail that includes boundaries for e-mail
      # attachments
      echo "To: $EMAIL_RECIPIENT"                              >> $LETTER
      echo "Subject: $SUBJECT"                                    >> $LETTER
      echo "MIME-Version: 1.0"                                    >> $LETTER
      if  [ "$ATTACHMENT" = "" ]
      then
        echo "Content-Type: Text/plain; charset=US-ASCII"           >> $LETTER
      else
        echo "Content-Type: Multipart/Mixed; Boundary=\"$BOUNDS1\"" >> $LETTER
        echo ""                                                     >> $LETTER
        echo "$BOUNDS2"                                             >> $LETTER
        echo "Content-Type: Text/plain; charset=US-ASCII"           >> $LETTER
      fi
      # now let's add the message's text body
      if [ -f $LETTER_BODY ]
      then
        cat $LETTER_BODY                                            >> $LETTER
      else
        Abort "Error. Letter body [$LETTER_BODY] not found!"
      fi
      # if we have an attachment, let's add it now
      if  [ "$ATTACHMENT" != "" ]
      then
        echo "$BOUNDS2"                                                   >> $LETTER
        echo "Content-Type: Text/plain; charset=US-ASCII; name=\"$BASE\"" >> $LETTER
        cat ${ATTACHMENT}                                                 >> $LETTER
      fi
    </font>The only real complexity is creating the boundary tags between attachment and the mail body - and of course specifying the correct e-mail headers so that the mail reader will know what is what.
    The above code creates a $LETTER file and this is then simply e-mailed using the Unix mail command, e.g.
    /usr/bin/mail $RECIPIENT < $LETTER
    More details in RFC 2045 - Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies. http://www.faqs.org/rfcs/rfc2045.html

  • Generate RMAN backup Script using unix shell script

    Hello,
    Could somebody give me a unix shell script that would generate RMAN script based on some user defined parameters in a config file.
    e.g.
    rman.conf
    CHANNELS=4
    USE_CATALOG=Y
    DEVICE='sbt_tabe'
    etc.,
    many thanks,
    kam

    You can actually encapsulate the RMAN commands inside the shell script.
    However if you really want to create a seperate RMAN script file, you can use the unix shell's "echo" command to write set variables to a file.
    Thus, for example,
    echo "rman target / catalog rman/rmanpassword@crcat" > RMAN_Script.rmn
    echo "backup database plus archivelog" >> RMAN_Script.rmn
    echo "backup archivelog all" >> RMAN_Script.rmn
    creates RMAN_Script.rmn with 3 commands.

  • Running report in concurrent manager using unix shell script to create PDF

    Hi,
    I need help urgently, we are in the process of migrating from 10.7 to 11i. My problem is we have a report created in 10.7 that is ran through concurrent manager using shell scripts(host) and the output is stored as .pdf, in 10.7, it works perfectly. Now I am also doing it in 11i but it gives some error. The shell script from 10.7 is: r25runm module=$XXX_TOP/srw/test.rdf \
    userid=$1 batch=yes \
    desformat=pdf destype=file \
    desname=$XXX_TOP/outbound/test.pdf
    I change the shell script in 11i as follows:
    ar60runb report=$XXX_TOP/reports/US/test.rdf \
    userid=$1 batch=yes \
    desformat=pdf destype=file \
    desname=$XXX_TOP/outbound/test.pdf
    I checked your metalink, and I am confused which is the right executable I should use, is it ar60runb or ar60run or rwrun60b or rwrun60c or rwrun60b, which is which? how many parameters do I have to include?, some documents are saying I have to use the 4 parameters-orauser/pwd, userid,username, request_id, others one.Which parameter/s go/es with what executable. We are using HP-UX server 64 bit. In 11i, when I run in concurrent manager it gives me an error:The executable file /chdev/fd11/u00/fd11appl/xxx/1.0/bin/test for this concurrent program cannot be executed.
    Contact your system administrator or support representative. Verify that the execution path to the executable file is co.
    I have checked Metalink and follow the directions, created a link fndcpesr, check and set the permissions, etc. Play around with the executables ar60runb or rwrun60 etc., the parameters. The ar60* or rwrun60* executable permissions are -rwxr-xr-x and $XXX_TOP/fnd/../fndcpesr is -rwxr-xr-x. Also, why is ar60* executables located in $FND_TOP/bin, whereas rwrun60* executables are in $ORACLE_HOME/bin? Please help, I need an answer urgently ,I have to complete this task before Tuesday 9/16/2003 for our migration deadline. Thank you very much.

    I have already fixed the problem, TY anyway

  • Send email attachments using Java through Outlook Express

    Hi
    Can anyone suggest how we can interface Outlook Express with java in
    order to send email?
    I want to add 'Email Friend' link in my project, on clicking on this
    link Outlook Express should open with a specified file attached.
    I searched on net also, but I am getting only JOC everywhere which is
    not freeware.
    Please suggest me on the same that how it can be done?
    Thanks
    Ashi

    You can send files to Outlook Express using following:
    using a windows exe runmenu. exe
           File file = new File("./lib/runmenu.exe");
            try
                String commandForNotesMail =
                    file.getCanonicalPath() +
                    " \"/exec: send to\\mail recipient\" " + filename;
                System.out.println("Cononical Path :" + commandForNotesMail);
                Runtime.getRuntime()
                    .exec(commandForNotesMail);
            catch (IOException e)
                e.printStackTrace();
            return true;
        }

  • Reg: UNIX shell script at File Adapter

    Hi all,
    I am doing a File to file scenario and using command line arguments in Sending file adapter. I am using UNIX shell script ".sh" file for executing the command.
    I gave the following path at "Run OS command before message processing" parameter:
    /temp/xidelivery/send/FILOSC004_shell.sh
    and this file contains following code:
    <b>#!/user/bin/sh cp /temp/xidelivery/send/FILOSC004_in.txt /temp/xidelivery/send/FILOSC004_input_copy4.txt</b>
    I put the source file, FILOSC004_in.txt and shell script files at the respective paths.
    If I give "cp" command directly in command line it is working fine. But I could not execute this with shell script. Can any body give me the reason where I gone wrong.
    Regards,
    Pavani.

    Hi,
    can you try this,
    bash /temp/xidelivery/send/FILOSC004_shell.sh
    let me know.
    hey you can check the blog below to catch the OS errors,
    /people/michal.krawczyk2/blog/2005/08/17/xi-operation-system-command--error-catching
    Prasad Babu.
    Message was edited by:
            PrasadBabu Koribilli

  • Schedule workbook using with Unix shell script

    Hi,
    Can we schedule workbook using with Unix shell script?
    Thanks,
    Jay

    I can't imagine how.
    1. You can schedule Disco workbooks via Disco itself.
    2. You can schedule Disco workbooks to run and output in different file formats automatically via batch scheduler in Windows running Disco Desktop directly (or can user VBasic).
    3. You can schedule Disco workbooks to run and output in different file formats automatically via a Java program running the Java Command Line interface.
    Moving forward, Oracle has announced that with a further interfacing of Disco with XML Publisher, you'll be able to use Oracle Apps concurrent manager and scheduling. But that's coming supposedly at the end of this year.
    And I think that's about it.
    Russ

  • Trouble sending email attachments or using photo mail

    Hi. I have Elements 6.0 and I'm using a HP computer with Vista. Starting about three days ago (for sure that I know of), I have not been able to send pictures by email attachment or photo mail in SHARE. I have been able to send pictures without problems in the past. When I "send" the pictures, everything looks fine (counting down of pictures sent displays and disappears as usual). When I pull down "find" and then "by history" and then "emailed to", its says my emails have been sent and how many pictures I have sent.
    So, that is my question. What has happened that I can't send email attachments anymore and how can I fix it?
    Thank you for any help or suggestions!
    Laura

    Well I had a brief moment of elation this am. All 26 of the test images I mailed to myself showed up in my mail box and my husbands. Thought it was all fixed. Tried to mail another and so far have not received it. Is it possible that the speed of delivery is REALLY slow? There has always been an inordinate lag time in receipt; about 7 to 10 minutes. But 3 days seems a little ridiculous. In the mean time I registered for the free adobe photoshop. It is bare bones, really easy, and it works. Their email does not have imbedded photos, but it does work. Just go to photoshop.com.

  • Executing Unix shell scripts with DBMS_SCHEDULER

    I have the following Unix shell script create_backup_file.sh:
    #!/usr/bin/ksh
    /usr/bin/ssh [email protected] /usr/bin/touch/app_home/home/trotestbat/scripts/TRO_batch_complete_`date +%d-%m-%Y-%H%M`
    If I execute this from the command prompt it creates the file on the remote server.
    I've used dbms_scheduler to try and execute this from Oracle:
    BEGIN
    SYS.DBMS_SCHEDULER.CREATE_PROGRAM
    program_name => 'CREATE_TRO_BACKUP_FILE'
    ,program_type => 'EXECUTABLE'
    ,program_action => '/APP/TORPEDO/DTE/SCRIPTS/create_backup_file_tro.sh'
    ,number_of_arguments => 0
    ,enabled => TRUE
    ,comments => NULL
    SYS.DBMS_SCHEDULER.CREATE_JOB
    job_name => 'DTE.TESTAGAIN'
    ,start_date => TO_TIMESTAMP_TZ('2010/05/17 16:09:24.710789 +01:00','yyyy/mm/dd
    hh24:mi:ss.ff tzh:tzm')
    ,repeat_interval => NULL
    ,end_date => NULL
    ,program_name => 'DTE.CREATE_TRO_BACKUP_FILE'
    ,comments => NULL
    END;
    The problem I have is that scheduler executes the shell script and creates the file but it never completes the job. The status of the job is permanently 'RUNNING'. Why is the scheduler not returning a completed status?

    the "infinite" script is usually caused by a prompt (script pauses for a user input).
    Please keep in mind that executing script via scheduler is not the same as manually via prompt.
    1. the script runs as ORACLE user ID (or whatever you specified using DBMS_SCHEDULER.create_credential or/and "$ORACLE_HOME/rdbms/admin/externaljob.ora")
    2. the environment variables are probably not the same.
    My wild guess is that you never ran SSH using "oracle" UID and thus it prompts for permission to add the remote computer’s fingerprint to the user’s ~/.ssh/known_hosts file - since it is a script, it just hangs and waits for input.
    Did you try to login to unix box as oracle uid and run the script manually?

  • Execute a unix shell script from forms9i

    Hi ,
    I would like to execute a unix shell script form a form when they pressed a button. The forms server is on Linux machine. I tried but when I pressed the button nothings happen. Could some one please help me how I could get working.
    Is there is a way I could execute the unix shell script from PL/SQL proceudre or package.
    Please some one help me.
    Bain

    You would not expect to see anything happening because the
    script cannot directly send output to the web form. However, you can get it to write output to a file and use web.show_document in the form after the host command to display the file and see the output.

  • Parameter transfer to tmloadcf from Unix shell script.

    Hi.
    I am using Tuxedo global transaction with database password encryption, so I replaced by ***** the database password in OPENINFO string of the TMS in the UBBCONFIG GROUP section.
    As a result the password should be inserted manually when running tmloadcf.
    Do you know how this password can be inserted from a Unix shell scripts?
    I tried to use << or named pipe (mkfifo) but in both cases the tmloadcf remained stuck.
    Thanks in advance for your help.
    Amnon Katz.

    Amnon,
    The C library function isatty() is used to determine if tmloadcf is
    associated with a terminal. If isatty(0) returns 0, then the tmloadcf code
    to prompt for a password will fail.
    In some places in Tuxedo, there is functionality to allow reading a password
    from an environment variable if the process requiring the password is not
    associated with a terminal. However, this functionality is not available
    for tmloadcf. If you have an active Tuxedo maintenance contract and the
    functionalty of reading a database password from an environment variable
    when tmloadcf is not run from a terminal is important to you, you may want
    to file a support case and request that this functionality be added to
    tmloadcf. Otherwise, you will have to run tmloadcf from a terminal.
    Regards,
    Ed
    <Amnon Katz> wrote in message news:[email protected]..
    Thanks Ed for your reply.
    Do you know how tmloadcf identify that descriptor 0 is associated with a
    terminal?
    Is it possible to write some code that can emulates this situation?
    Regards,
    Amnon

  • Calling a report from unix shell script

    Hi,
    I had to call a report from unix shell script.
    May i know the procedure to accomplish this
    Thanks in Advance
    A.Gopal

    First you should not include the whole path to your report in the call ...
    Use like this:
    /ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
    In $ORACLE_HOME/bin/reports.sh:
    1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
    REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
    2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
    After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
    If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
    i.e.
    Change the following line:
    <!--trace traceOpts="trace_all"/-->
    to <trace traceOpts="trace_all"/>
    Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look.

  • How can i call a Stored Procedure procedure from Unix shell script

    Hi All,
    I want to call a Strored PL-SQL Procedure through Unix shell script.
    Can any body help me with this.
    Regards,
    Saurabh

    I prefer a seperate script like the other poster mentioned. However, most shells can use a 'here' document as well ...
    sqlplus uid/pwd <<END
    exec myproc
    exit
    ENDRichard

  • Error while trying to execute a unix shell script from java program

    Hi
    I have written a program to execute a unix shell script in a remote machine. I am using J2ssh libraries to estabilish the session connection with the remote box.The program is successfully able to connect and authenticate with the box.
    The runtime .exec() is been implemented to execute the shell script.I have given below the code snippet.
    try {
         File file_location = new File("/usr/bin/");
         String file_location1 = "/opt/app/Hyperion/scripts/daily";
         String a_mib_name = "test.sh";
         String cmd[] = new String[] {"/usr/bin/bash", file_location1, a_mib_name};
         Runtime rtime = Runtime.getRuntime();
         Process p = rtime.exec(cmd, null, file_location);
    System.out.println( "Connected to the server1" );
    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line = br.readLine();
    while(line !=null)
    System.out.println(line);
    line = br.readLine();
    br.close();
    p.getErrorStream ().close ();
    p.getOutputStream().close();
    int retVal = p.waitFor();
    System.out.println("wait " + retVal);
    //session.executeCommand("ls");
    catch (IOException ex) {
    I get an error message
    Connected to the server
    java.io.IOException: Cannot run program "/usr/bin/bash" (in directory "\usr\bin"
    ): CreateProcess error=3, The system cannot find the path specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at SftpConnect.main(SftpConnect.java:143)
    Caused by: java.io.IOException: CreateProcess error=3, The system cannot find th
    e path specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    I am sure of the file path where the bash.sh and test.sh are located.
    Am i missing something? Any help would be greatly appreciated.
    Thanks
    Senthil

    Hi, I am using a simple program to connect to a RMI server and execute shell script. I use the Runtime.exec aommand to do the same.
    The script is sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul
    The script when run from the server, gives no errors. But when ran using rthe above method in java, gives errors as follows,
    Mycode:
    String command = "/bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul";
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(command);
    int exitVal = proc.exitValue();
    System.out.println("Process exitValue: " + exitVal);
    java.io.IOException: CreateProcess: /bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul error=3
         at java.lang.ProcessImpl.create(Native Method)
         at java.lang.ProcessImpl.<init>(Unknown Source)
         at java.lang.ProcessImpl.start(Unknown Source)
         at java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at DecryptTest.main(DecryptTest.java:18)
    Can anyone please help

  • Error while executing unix shell script from java program

    Hi All,
    I am trying to execute unix shell script from a java program using Runtime.execute() method by passing script name and additional arguments.
    Code snippet :
    Java Class :
    try{
         String fileName ="test.ksh";
         String argValue ="satish"; // value passed to the script
         String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
         Process proc = Runtime.getRuntime().exec(exeParam);
         int exitValue = proc.waitFor();
         sop("Exit Value  is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    }Test.ksh
      export -- application realated paths..
      nohup  abc.exe 1> test.log 2>&1;
      $1
      exit.By running the above java class , i am getting exit Value: 139 and log file test.log of 0 bytes.
    when i am running the same command (/usr/bin/ksh test.ksh satish) manually, it's calling abc.exe file successfully
    and able generate the logs properly.
    Pls let us know where exactly i am stuck..
    Thanks in advance,
    Regards,
    Satish

    Hi Sabre,
    As per the guidelines provided by the article, i had done below changes..
    InputStream is = null;
    InputStreamReader iStreamReader = null;
    BufferedReader bReader = null;
    String line = null;
    try{
    String fileName ="test.ksh";
    String argValue ="satish"; // value passed to the script
    String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
    Process proc = Runtime.getRuntime().exec(exeParam);
    is = proc.getErrorStream();
    iStreamReader = new InputStreamReader(is);
    bReader = new BufferedReader(iStreamReader);
    System.out.println("<ERROR>");
    while((line = bReader.readLine()) != null)
    System.out.println("Error is : "+line);
    System.out.println("</ERROR>");
    int exitValue = proc.waitFor();
    sop("Exit Value is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    Now , it's showing something like..
    <ERROR>
    </ERROR>

Maybe you are looking for

  • Netweaver 2004s SR3 PI 7.0 Installation Error

    Hi All, I am installing Netweaver 2004s SR3 PI 7.0 on Sun Solaris 10 and Oracle 10g, all the components are  64bit version. During the installation step 95 out of 98 prepare to install minimal configuration ended with error. please find here the belo

  • Exchange mail account doesn't work anymore in MBP

    Hello everyone I am new to Apple products. I purchased my MBP 13" in Aug 2013. Since then I have been facing issues with Mail app in my MBP. I use Exchange account from my office (Exchange server 2003) and I got the settings from my administrator. I

  • How do I get Itunes to read my itouch?

    I updated my Itunes to the latest version and ever since I did that, Itunes isn't reading my itouch. I went through the steps on the Apple Support page, but it still isn't reading it. Is there any other way to get Itunes to read my Itouch?

  • S_PL0_86000030 report

    Hi all, In the report S_PL0_86000030 of G/L balances, my user is not getting the name of the company in the report. Please help in this regard. Ashok

  • PDF documents send blank on my Mac Book

    When I fill in information on a PDF and save it to my desk top. I send it as an attachment but when it arrives at end user the info is blank