Please help me: what is the wrong in my code?

Hi all ,
I wrote a script in unix to send a mail, i am executing the script using java code, when i test the script separately in unix it is working properly , when i am executing it in java it is not working properly it is not showing any errors.
UNIX script: Send_mail.ksh
#!/bin/ksh
. ./set_mail_details.ksh
echo 'In script'
subject=$1
echo '\nsubject'
echo $1
echo "$subject" | sed 's/~/ /g' | read sub
body_of_email=$2
echo '\nBody'
echo $2
echo '\nMail List'
to_list=$3
echo $3
echo "$body_of_email" | sed 's/~/ /g' | read body
(echo "$body";echo '\n';cat U.CUE_CPM )| mailx -s "$sub" -r [email protected] "$to_list"
if [ $? -eq 0 ]
then
  echo "Mail is Sent"
else
  echo "Mail is not sent(In script)"
fijava code: sendMail.java
import java.lang.*;
import java.util.*;
import java.io.*;
public class sendMail
  public static void main(String argv[])
      /* This function will send a mail.*/
          String mailIds = "[email protected],[email protected]";
          try{
               String subject="Test mail";
                   String body = "This is to test the code";
                   String exec_command = "send_mail.ksh "+subject+" "+body+" "+mailIds;
                   Process p = Runtime.getRuntime().exec(exec_command);
                        int exitVal=p.waitFor();
                        if (exitVal == 0)
                                System.out.println("Mail Is Sent Successfully");
                        else
                                System.out.println("Mail Is Not Sent ");
                 catch(Exception e)
                    System.out.println("Mail Delivary Failure due to following reasons.");
                        System.out.println("error in email:"+e.getMessage());
                        System.out.println("Cause:"+e.getCause());
                        System.out.println("to string:"+e.toString());
}when i execute the sendMail i am getting the output as
$ java sendMail
Mail Is Sent Successfully
but i didn't receive any mail.can any one please help in resolving my prob :((

When using Runtime.exec(String) method, the parameter is split by whitespaces. The first token being the program to run, and each other being considerred as an argument to this program.
In your test, the body contains whitespaces. Therefore, "This" is considered as one argument, and "is" as another one (mail list in this case...), etc.
You should consider using the Runtime.exec(String[]) method instead, whith which you have control on the parameters (the first element of the array being the command and every subsequent element being an argument.)String[] exec_command = {"send_mail.ksh", subject, body, mailIds};
Process p = Runtime.getRuntime().exec(exec_command);http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html
Tim - What about JavaMail ?

Similar Messages

  • TS1424 Hy. Please help me. what's the problem? when i accessing icloud or find my friend app: The maximum number of free accounts have been activated on this iPhone.

    Hy. please help me. what's the problem? when i accessing icloud or find my friend:The maximum number of free accounts have been activated on this iPhone.

    Then you'll have to use another iOS device or Mac running OS X Lion or higher to create a new account for you to use on your phone.  If you don't have one, perhaps a friend would allow you to create and account on their device (note: this will use one of their three maximum accounts).  To do this, they would need to go to Settings>iCloud, tap Delete Account (which will delete the account from their device but not from iCloud), then allow you to sign back in with your ID to create the new account.  Then tap Delete Account to delete the new account from their device, and finally, sign back in with their iCloud ID to restore their iCloud account to their device.  Then you can sign in with your ID on your phone in Settings>iCloud and use the new account.

  • Please tell me what is the problem with this code

    Hai,
    Iam new to Swings. can any one tell what is the problem with this code. I cant see those controls on the frame. please give me the suggestions.
    I got the frame ,but the controls are not.
    this is the code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
    JButton b1;
    JLabel l1,l2;
    JPanel p1,p2;
    JTextField tf1;
    JPasswordField tf2;
    public ex2()
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setTitle("Another example");
    setSize(500,500);
    setVisible(true);
    b1=new JButton(" ok ");
    p1=new JPanel();
    p1.setLayout(new GridLayout(2,2));
    p2=new JPanel();
    p2.setLayout(new BorderLayout());
    l1=new JLabel("Name :");
    l2=new JLabel("Password:");
    tf1=new JTextField(15);
    tf2=new JPasswordField(15);
    Container con=getContentPane();
    con.add(p1);
    con.add(p2);
    public static void createAndShowGUI()
    ex2.setDefaultLookAndFeelDecorated(true);
    public static void main(String ar[])
    createAndShowGUI();
    new ex2();
    }

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
        JButton b1;
        JLabel l1,l2;
        JPanel p1,p2;
        JTextField tf1;
        JPasswordField tf2;
        public ex2()
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setTitle("Another example");
            b1=new JButton(" ok ");
            p1=new JPanel();
            p1.add(b1);
            p2=new JPanel();
            p2.setLayout(new GridLayout(2,2));
            l1=new JLabel("Name :");
            l2=new JLabel("Password:");
            tf1=new JTextField(15);
            tf2=new JPasswordField(15);
            p2.add(l1);
            p2.add(tf1);
            p2.add(l2);
            p2.add(tf2);
            Container con=getContentPane();
            con.add(p1, BorderLayout.NORTH);
            con.add(p2, BorderLayout.CENTER);
            pack();
            setVisible(true);
        public static void createAndShowGUI()
            ex2.setDefaultLookAndFeelDecorated(true);
        public static void main(String ar[])
            createAndShowGUI();
            new ex2();
    }

  • HT201272 The songs that I want to get are not appearing, please help! What is the problem?

    Someone help VERY FAST!

    Probelm solved -_- But if anyone could explain why it happened that would help

  • Please help! What is the latest vesrion of Apache web server for

    Oracle Forms 10G.
    Regards,
    Evgeny

    that means Apache 1.33.2?
    Or simply Apache 2?
    thing is that I have a stand alone installation of FORMs 10G and Apache is a piece of that as I understand, so in need to upgrade apache from 1.33.2 to the latest version of apache, so it will be apache 2? or there is no upgrade further?
    Regards,
    Evgeny

  • Please, help me, What is the difference between SCWCD and SCBCD ?

    {color:#000000}*HI, Everyone*
    I want to know major difference between Sun Certified Business Component Developer and Sun Certified Web Component Developer.
    Who should go for business component developer and who should go for web component developer?
    It would be great if somebody can give 1 or 2 examples of application which can be developed by business component developer or web component developer.
    Thank you {color}
    Edited by: Xpero on Aug 19, 2010 9:19 AM

    Do you think writing in bold will make people more interested in your post? It doesn't. It's just annoying.

  • What is the wrong in this code

    *& Report  ZTESTTEST
    REPORT  ztesttest LINE-SIZE 256.
    TYPE-POOLS: slis.
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE ,
                   <dyn_wa>,
                   <dyn_field>.
    FIELD-SYMBOLS: <dyn_table1> TYPE STANDARD TABLE ,
                   <dyn_wa1>,
                   <dyn_field1>.
    DATA: alv_fldcat TYPE slis_t_fieldcat_alv,
          it_fldcat TYPE lvc_t_fcat.
    TYPE-POOLS : abap.
    DATA : it_details TYPE abap_compdescr_tab,
           wa_details TYPE abap_compdescr.
    DATA :itab TYPE abap_component_tab.
    *       CLASS cl_my_structure  DEFENITION
    CLASS cl_my_structure DEFINITION.
      PUBLIC  SECTION.
        METHODS: x.
      PROTECTED SECTION.
      PRIVATE SECTION.
    ENDCLASS.                    "cl_my_structure  DEFENITION
    *       CLASS cl_my_structure IMPLEMENTATION
    CLASS cl_my_structure IMPLEMENTATION.
      METHOD x.
        WRITE 'HI'.
      ENDMETHOD.                    "x
    ENDCLASS.                    "cl_my_structure IMPLEMENTATION
    DATA : ref_descr TYPE REF TO cl_abap_structdescr.
    DATA: new_table TYPE REF TO data,
          new_line  TYPE REF TO data,
          wa_it_fldcat TYPE lvc_s_fcat.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text .
    PARAMETERS: p_table(30) TYPE c DEFAULT 'T001'.
    SELECTION-SCREEN END OF BLOCK b1.
    * Get the structure of the table.
    ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).

    That depends on what you want it to do.  Do you want it to write "Hi"?  If so...
    report  ztesttest line-size 256.
    *type-pools: slis.
    *field-symbols: <dyn_table> type standard table ,
    *               <dyn_wa>,
    *               <dyn_field>.
    *field-symbols: <dyn_table1> type standard table ,
    *               <dyn_wa1>,
    *               <dyn_field1>.
    *data: alv_fldcat type slis_t_fieldcat_alv,
    *      it_fldcat type lvc_t_fcat.
    *type-pools : abap.
    *data : it_details type abap_compdescr_tab,
    *       wa_details type abap_compdescr.
    *data :itab type abap_component_tab.
    *       CLASS cl_my_structure  DEFENITION
    class cl_my_structure definition.
      public  section.
        methods: x.
      protected section.
      private section.
    endclass.                    "cl_my_structure  DEFENITION
    *       CLASS cl_my_structure IMPLEMENTATION
    class cl_my_structure implementation.
      method x.
        write 'HI'.
      endmethod.                    "x
    endclass.                    "cl_my_structure IMPLEMENTATION
    *data : ref_descr type ref to cl_abap_structdescr.
    *data: new_table type ref to data,
    *      new_line  type ref to data,
    *      wa_it_fldcat type lvc_s_fcat.
    data: o_ref type ref to cl_my_structure.
    selection-screen begin of block b1 with frame title text .
    parameters: p_table(30) type c default 'T001'.
    selection-screen end of block b1.
    start-of-selection.    "<--  YES, YOU NEED THIS.
    create object o_ref .
    call method o_ref->x.
    * Get the structure of the table.
    *ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
    Regards,
    RIch Heilman

  • HT4113 When I go for restrictions my iPad mini want my pass code I fill it's recurarment it's say wrong please help me what I do....?

    When I go for restrictions my iPad mini want my pass code I fill it's recurarment it's say wrong please help me what I do....?

    Hey there Ajjusingh,
    It sounds like the passcode you are entering for your Restrictions is not working for you. According to the following article you will need to perform a factory restore to reset that passcode:
    iOS: Understanding Restrictions (parental controls)
    http://support.apple.com/kb/ht4213
    Note: If you lose or forget a restriction passcode, you will need to perform a factory restore to remove it.
    Thank you for using Apple Support Communities.
    All the very best,
    Sterling

  • I Just updated the software of my iphone 4s thru phone, now the photo application won't open... Please help me what to do?

    Hi! I'm Ralph.. Just updated my iphone 4s from 6.1.2- 6.1.3. ... Now the photo application won't open... Please help me what to do

    Why would this be covered under warranty?  There is nothing wrong with the device, it simply needs to be restored.
    As already stated twice in this thread, disable ALL security software on the computer and restore the device.

  • Hi can you please help me to fix my iPhone 5 when I update it to the iOS 6.1.2 my carrier signal indicator states searching all the time please help me what to do

    HiHi can you please help me to fix my iPhone 5 when I update it to the iOS 6.1.2 my carrier signal indicator states searching all the time please help me what to do

    Hi Samantha,
    Are you aware that if you restore your ipad that you will lose all data from your ipad and very difficult to get it back unless you had previously made a back-up of your data on itunes or in the cloud. and that would be on the computer you set those up on. (There are some independent apps out there that might help restore data but I don't have any experience with them...)
    Also, I think if you restore on another computer you're supposed to have administrator rights and have the latest itunes update. And I think if you sync (if restoring is considered syncing with another computer, you'll be locked out of your computer or a new one.)
    I don't know if there is a way for you to safely eject your ipad from your mom's laptop and find another way, but please read this
    http://support.apple.com/kb/ts1275
    Also, I suggest you start a new post and title it something like First, stuck on update and now on Restore on another computer. Please HELP! And then tell the story of your problem that you originally included and your follow-up efforts to restore given a suggestion on previous post (though I think you SHOULD AVOID RSTORE if you can.) And refer them to your original post
    https://discussions.apple.com/message/22050045?ac_cid=tw123456#22050045
    Hope this helps and if you can get back to your ios before the upgrade, stay with it. I hope it all works out for you.
    FYI - If it's a new or refurb bought within the past year you might be able to have it replaced by Apple.

  • HT201210 My iPhone has crashed and i went to iTunes to restore it and after waiting for it to be restored it said "The iPhone could not be restored. An unknown error occurred (2006). Can anybody please help suggest what i should do now?

    My iPhone has crashed and i went to iTunes to restore it and after waiting for it to be restored it said "The iPhone could not be restored. An unknown error occurred (2006). Can anybody please help suggest what i should do now?

    This error normally appears if you attempted to downgrade or modify your iOS. See here http://support.apple.com/kb/TS3694#error1015

  • TS3682 I started updating my iPhone 4, but it went black screan and then started turning on and off non stop. I tried to hold the two buttons, but nothing different happened. Please, help! What should I do?!

    I started updating my iPhone 4, but it went black screan and then started turning on and off non stop. I tried to hold the two buttons, but nothing different happened. Please, help! What should I do?!

    First see if placing the iPod in Recovery Mode will allow a restore.
    Next try DFU mode and restore.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    If not successful then time for an appointment at the Genius Bar of an Apple store. You are not alone with this problem.

  • I have a question, why is it I can't purchase a app at App Store it says "Your payment method is not valid in this store" and I've got a Visa card and my location is in the Philippines. Please help me, what can I do?

    I have a question, why is it I can't purchase a app at App Store it says "Your payment method is not valid in this store" and I've got a Visa card and my location is in the Philippines. Please help me, what can I do?

    Your visa card is a credit card, not debit card?  Do you meet the requirements as below, interpreted strictly?
    Philippines - http://www.apple.com/legal/itunes/ph/terms.html - "The iTunes Store, Mac App Store, App Store, and iBookstore services (the "Stores") accept credit cards issued by banks in the Philippines or Content Codes as forms of payment."

  • HT4759 Hi I cannot sign up to my iCloud account I forgot the password I want to buy some additional GB to my iPad..please help me what to do

    Hi I cannot sign up to my iCloud account I forgot the password I want to buy some additional GB to my iPad..please help me what to do

    Please be aware that you cannot "buy some additional GB to [your] iPad"; the storage capacity of the iPad is fixed at the time of manufacture. You can buy additional iCloud storage, but that's not the same thing.

  • Ipad didnt work, i cant go back to the apps, and even i cant reboot the ipad. please help me, what should i do with my ipad? thank you.

    i read a book from ipad, when i want to change to a game, suddenly the ipad stuck. i cant go back home or even reboot from the turn on/off button, and now the ipad stuck. please help me, what should i do? thank you.

    If "Demo's" instructions helped...
    when i want to change to a game,
    Tap and hold down the app then tap the x with a circle then tap Delete.
    User your iPad for a few days to see if it's stable. If it is, then it's that one app causing the problem.
    Contact the app's developer (at their website) for support.

Maybe you are looking for

  • K7n2 delta-l question:)

    Hi all, K7N2 Delta-L is a new board for me, and day by day I discover new things, some are positive, others are negative:) Today I want to ask you about some negative aspects: 1. When I want to set the Vcore of the CPU at 1,55V (in fact I want to set

  • Owners of the 80GB iPod classic, I have a few questions

    Ok, so I got my 80GB black iPod classic today and have a few questions, one of these I will need you to check something on your classic. 1: Can you get the digital booklets from the albums purchased on the store on your classic? 2: Is it normal for t

  • Starting Weblogic 6.1 failure extracting WAR classes

    Hi there, I'm getting several error-messages when starting my weblogic 6.1 saying: <Jan 10, 2002 9:07:32 AM CET> <Error> <HTTP> <[WebAppServletContext(4057696,cert ificate,/certificate)] failure extracting WAR classes java.io.IOException: Permission

  • HPCM Deploying of DB / Apps

    Hi I'm new to HPCM. Can someone let me know what gets deployed when we do the HPCM apps deployment from EPMA. Further what artifacts stored in RDBMS / Essbase of an HPCM apps. While deploying calc / reporting db from HPCM the deploy option is not ava

  • Installing adobe encore

    Hi, I've updated to adobe CC 2014 and I don't know how to install adobe encore. I read the help but it's about the previous version of adobe cc. Thank you