Ran into an interesting problem with getRuntime().exec()

Hi,
I'm trying to run a application using getRuntime().exec(). When I run the prgram from the command prompt everything goes ok, but when I start it from my java application, I get and error and the program exits.
The executable I call withing my application is a bat file that sets the neccessary environmental variables (for now) and executes the right exe files. Exactly the same bat file I can start at the command prompt. I've also tried calling cmd /c to start the program and directly calling the exe started by the bat file.
Below is the error I get. I have a hunch the program is made with Fortran.
Can't read communication file
Filing error number 7: FNF:File not found
: Unable to open communications file to read
There should be nothing wrong with my code and I can read and control the program. The problem occures when I try to change the mode withing the program, that makes it try to start a new process.
What's the difference between starting a program manually through the command prompt and executing it using getRuntime().exec()?
Br,
Tom

I'm just wondering how exec() can be different from using the command line in windows. I even execute my java app in the same directory and it uses the same commands.

Similar Messages

  • Problems with getRuntime().exec()

    Hello!
    I'd like to start a process which will run a C executable.
    The C executable named dbc is placed in the folder
    /home/swkm/services/rul_hyb/rul-1.0/bin and accepts as an argument the name of a database, for example, myDB
    I tried the following code:
       File f = new File(filePath);
              Process process = Runtime.getRuntime().exec
                   new String[]
                        "dbc",
                        "myDB"
                   }, null,f
              );where filePath is the above mentioned path.
    The problem is that I receive an:
    java.io.IOException: java.io.IOException: dbc: not found
         at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
    I tried the new Tiger version of ProcessBuilder in the following manner:
    ProcessBuilder process = new ProcessBuilder
                   new String[]
                        "dbc",
                        "myDB"
                  process.directory(new File(path));
                  Process p=process.start();but I got the same exception: "dbc not found"
    Do you have any idea what is going wrong?
    Thank you very much
    With best regards,
    Sorin

    Are you assuming that the executable executes from the directory defined by 'filePath' ? If so then this is wrong - the executable must be in a directory in the PATH environment variable or you must specify the full path to the executable.
    The third argument in the exec() command is the working directory for the process and does not modify the PATH environment variable.
    P.S. It does not matter whether you use Runtime.exec() or ProcessBuilder becauuse behind the scenes Runtime.exec() just wraps ProcessBuilder.
    Message was edited by:
    sabre150

  • Problem with Runtime.exec()

    Hi,
    I'm having a problem with Runtime.exec() . I have a batch file with debug option to FTP the desktop file to mainframe. When I executed this in Windows it's shows me the responce from the server (like ' Transfer Completed' ) for my FTP commands. But when I launch this through java it's only shows the errors not the normal responces from the server. I need this responses to confirm the proper transfer of file.
    My Java Code:
    String strCommand = "cmd.exe /c " + outdirectory + batchfilename;
    boolean bWait = true;
    Runtime r = Runtime.getRuntime();
    Process pr = r.exec(strCommand);
    BufferedInputStream bis =new BufferedInputStream(pr.getInputStream ());
    int c=0;
    /** Outlet for IO for the process **/
    while (c!=-1) {
    c=bis.read();
    /**Now wait for the process to get finished **/
    if(bWait == true){
    pr.waitFor();
    pr.destroy();
    My Batch file is :
    FTP -n -d -s:C:\IT2.cmd > C:\tIT2.log
    EXIT
    Thanks
    Sathiesh

    Ahh, you are redirecting the standard out from the ftp command to a file, therefore no output is sendt back to your java code,
    you have to redirect the stderr stream, not the stdout stream in your batch file;
    FTP -n -d -s:C:\IT2.cmd 2> C:\tIT2.log(notice the "2>" instead of ">")
    Now your batch file should direct the error stream to the log, and the standard output back to the java program.
    (I'm used to UNIX streams, not NT, but the "2>" redirection should work on NT also I guess)

  • Can anyone help me figure out how to use my new LaCie external hard drive to import movies from my camcorder into imovie '09? I ran into so many problems last night!! Was up way past my bedtime!

    Can anyone help me figure out how to use my new LaCie external hard drive to import movies from my camcorder into imovie '09? I ran into so many problems last night!! Was up way past my bedtime!

    I'll stay in this chat ... I answered in the other one ... I have a Sony digital Handycam ... from years ago.  I just got the LaCie and I think I formatted it for only to be used on my Mac ... how should I go about reformatting it to be HFS Extended like you said?

  • Why do we run into stupid basic problems with firefox?

    I have jre1.6_u31 installed on a Windows 7 and the brilliant
    firefox keep tell me that I've to install the jre_1.6_u29 missing plugin when I try to run an applet...a simple applet!! The plugin doesn't appear on add-ons manager then i use "check your plugins" and the stupid response is: "For your safety, Firefox has disabled your outdated version of Java. Please upgrade to the latest version."
    Running an applet is basic! Why are u making new versions when older ones are better? I' m sick of running into this stupid problems with firefox! Everything works on ie, chrome and safari but not on Firefox!
    I' m sick of trying to solve firefox basic problems!
    We have a site that has one thousand ore more visits per day...and we only have troubles with firefox! What do I tell the costumers? I' m not going to give them solutions difficult and confusing as usually your solutions are! They are common people not developers as me...they just want the things to work! I gave up and the solution that I give to them now is to stop using firefox and uninstall it. And people ask I chrome is becoming the second most used browser...here is your answer...
    I' m a developer and I've to develop I don't have the time patiente to trying solving basic firefox problems. If you don't know how to solve the problems then stop developing this and save us the headaches.

    Have you updated Java lately? You say you have jre1.6_u31 installed, but "Java(TM) Platform SE 6 U31" is not showing in the Plugins submitted with your question (click "More system details" to the right of your original question post). To enable, Add-ons > Plugins, and enable the item.
    If your OS is 64-bit and you have 32-bit browsers (Firefox) and 64-bit browsers installed, then you need to install both the 32-bit and 64-bit versions of Java.
    *See --> https://www.java.com/en/download/faq/java_win64bit.xml
    '''Older versions of Java blocked in Firefox''' --> https://addons.mozilla.org/en-US/firefox/blocked/p80 <br />
    '''Using/Updating Java''' --> [https://support.mozilla.org/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox] <br />
    '''Unblocking Java''' --> https://support.mozilla.org/en-US/kb/unblocking-java-plugin
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • You are enabling official branding. You may not redistribute this build * to any users on your network or the internet. Doing so puts yourself into * a legal problem with Mozilla Foundation

    You are enabling official branding. You may not redistribute this build
    * to any users on your network or the internet. Doing so puts yourself into
    * a legal problem with Mozilla Foundation

    "Firefox" is a trademark of the Mozilla Foundation. If you are building yourself, you are creating an "unofficial build." Unless you have a trademark license from Mozilla, you are not supposed to brand it as "official" and give it to others, since it implies that your build is endorsed by Mozilla. That is why Debian's build of Firefox is called "Iceweasel."
    For more information, please read [http://www.mozilla.org/foundation/trademarks/policy.html Mozilla's trademark policy].

  • Problem with runtime.exec().It hangs Up

    Hi all,
    I am having a problem with the runtime.exec method.I am trying to execute linux commands using this method.For most of the commands it works fine.But when i tried to change the user with the su command in linux my program hung up.So please help me to get around this.any help would be highly appreciable..
    I am pasting the code..
    <code>
    Process p=null;
    int ch=0;
    try
    System.out.println("Before executing command");
    String unlock_command="sh changeuser.sh";
    p = Runtime.getRuntime().exec(new String[] {"/bin/sh","-c","su tony"});
    InputStreamReader myIStreamReader = new InputStreamReader(p.getInputStream());
    while ((ch = myIStreamReader.read()) != -1)
    System.out.print((char)ch);
    p.waitFor();
    int p_exitvalue = p.exitValue();
    System.out.println("After executing the command and the exit value = "+p_exitvalue);
    p.destroy();
    catch (IOException anIOException)
    System.out.println(anIOException);
    catch(Exception e)
    e.printStackTrace();
    </code>
    Thanks
    HowRYou

    Hi sabre,
    What you have pointed out is right.But if i change the user as root then it will not ask for a password.Isn't it.Anyway thank you for giving your suggestions.Can yoiu help me more.Waiting for all of your help.I will try to swoitch between different users othere than root by giving the password.So just help me.

  • Ran into some new problems while overclocking

    First: this is a long post
     A couple months ago I had my system stable overclocked to 3.38ghz cpu (stock voltage) Ram was overclocked to 1000mhz 5-5-5-15 2.1v (same voltage as stock - in my sig) only have 2x1gb sticks then.
    slightly increase in performance, roughly 5fps increase in cod4 from stock frequencies. System was completely stable via prime 95 and memtest and used those settings for 4-5 months no problems.
    I recently (within past 2 months) upgraded my Ram since I was installing vista. I added 2 more 1gb sticks of the same exact memory (rated at 4-4-4-12 1T at 2.1v by corsair). ran memtest no problems. I also ran memtest at overclocked settings of 1000mhz 5-5-5-15 with the rest being set to auto and it was stable for 1 complete pass no errors.
    Ran prime 95 no problems.
    Then decided to try and push my overclock to the limit without increasing voltage. I managed to get up to a 3.5ghz stable in prime 95 for 3 hours (all tests for small ffts were completed then started the tests all over again) with my ram overclocked to 1000mhz as I mentioned above. had no luck overclocking past that even when increasing the voltage, but im not making this post to figure out why not.
    I decided to run call of duty 4 recently (single player); multiplayer ran smoothly and that's about all I was playing before.
    And that's when I started having problems. I noticed I was getting far less FPS than I should. Charlie don't surf level with max settings (1680x1050, 4aa, extra texture settings, full AF) was dropping into the teens in FPS during the helicopter scene right before landing. Then on Bog when defending the tank I was getting even less FPS with an average of like 25fps. (used fraps to benchmark) So I tried booting into windows xp to see if that solves that lag. It didn't, still lag.
    The last time I had played COD4 singleplayer was when I did not have 4gb of ram or vista installed. my system was what I stated in the first line of this post (3.38ghz, 1000mhz 5-5-5-15 2x1gb). On that SAME LEVEL I was getting (fraps benchmarks again) an average of 53fps on bog dropping down to about 48fps around the tank. HUGE DECREASE IN PERFORMANCE!!!
    So I decided to reduce the overclock on my cpu back down to 3.38ghz (ram was still overclocked to 1000mhz 5-5-5-15 4x1gb) since I knew that speed has been stable.
    I got maybe a 5fps increase but still very unplayable on bog with an average of 30fps and frequent dips below 25fps. I was like " ???"
    I then dropped all Overclock and went back to stock 3ghz cpu 800mhz ram (4-4-4-12-1T) and tried again. This time it was perfect. average FPS on bog was 48 FPS (intro part) and around 43 FPS average when defending the tank. minimum dip during that time was 30fps but I didn't even notice it.
    So I'm baffled... my system was stable at the higher overclocks, I used prime95 and memtest to confirm that for several hours. Temps on my cpu under full load in prime95 get up to about 56C and 51C max with idle being 35C 31C (per core respectively). (overclocked that is) stock it is maybe 4C lower for both. Yet for some reason perform horribly in COD4 compared to Stock speeds on both RAM and CPU. I did try overclocking cpu back to 3.38ghz while leaving RAM at stock speed and still had horrible lag. Seems I can't overclock anymore.
    The specifics on my motherboard are: MS-7380 (model) Bios V1.2B5 (6/23/2008).  (had to upgrade to newest beta bios to fix video playback corruption problem that has been plaguing nforce mobos - check nvidia nforce forums if you don't believe me.)
    Any clues as to why this is happening?
    edit: just to clarify - Intel Xeon e3110 is the same exact processor as the core 2 duo 8400

    ive tried it at 800mhz and 1000mhz. but now for some wierd reason after i started messing with teh overclocks i got my overclock settings 3.5ghz and 1000mhz ram 5-5-5-15 to work decently again. stock settings started to suck for some wierd reason too like it did when it was overclocked. this was in COD4 though.
    i have a feeling its only related to call of duty 4. ill list some benchmarks below
    -Stock speed on ram and cpu:
    cod 4 bog tank min: 17 max: 52 Avg: 31
    3dmark vantage
    P6026
    GPU 4837
    CPU 22962
    3dmark06
    10374 3DMarks
    SM 2: 4617
    SM 3: 4576
    CPU: 2676
    -3.38ghz 1000mhz 5-5-5-15
    cod 4 bog tank min: 27 max: 58 Avg: 39.5
    -cpu 3.5ghz ram 1000 auto timings
    cod 4 bog tank min: 14 max: 60 Avg: 22.3
    3dmark vantage
    P6073
    4872
    23327
    3dmark06
    10758 3DMarks
    4630
    4577
    3143
    cpu 3.5ghz ram 1000 5-5-5-15
    cod 4 bog tank min: 30 max: 56 Avg: 40.533
    vantage
    P6043
    4840
    23718
    3dmark06
    10724 3DMarks
    4616
    4555
    3142
    seems 3dmark is the only one that scaled well with every overclock and stock. ive tried doing the halflife 2 lost coast stress test max settings with vsync and got same exact fps from full overclock vs stock settings.
    dunno whats wrong but at least my overclock is running now. possibly a driver problem?
    I havent had much problem overclocking my ram. ive tried 1066mhz, havent memtested but i dont want to go too high overclock on ram in case they overheat or burn out or w/e

  • Problem running getRuntime().exec()--Urgent!!!

    hello,
    I am gathering system information and have been successful in getting parameters from the /proc directory of linux. But I have been unable to get the Total CPU usage info. So i used the 'top' command to get this info. The following code basically tries to capture the result of 'top' and push it into a file. After that is done i can basically loop it and get the result dynamically.
    This code but is not working properly. I tried cmd as a string and also as an array String[].......but its not working.
    I have tried 'top -bn1 >topf.txt' but somehow the program doesnt run. Could you please tell me where I am going wrong and the solution for the same....
    The code is as follows.....
    import java.io.*;
    class aniclient1
    public static void main(String args[])
         String[] cmd={"top","-bn1",">","topf.txt"};
         //String cmd="top -bn1 > topf.txt";
    // File topf=new File("topf.txt");
         try{
         //FileWriter out= new FileWriter(topf);
         Process p = Runtime.getRuntime().exec(cmd);
         p.waitFor();
         /*BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
         String data22;
         while ((line=in.readLine())!=null)
              data22=line;
              out.write(data22);
              System.out.println(line);
         out.close();
    catch (IOException e)
         //println(e.toString());
         catch(InterruptedException e2)
         //dasdas
    I have tried out all possible combinations with and without ">topf.txt" and top -n1....but it simply doesnt work. Can you please copy the code and run it so its fullproof. The above code works perfectly for "ls -C" but not for "ls -C>topf.txt".

    Maybe you're doing waitFor() in the wrong place, this works for meimport java.io.*;
    public final class Aniclient1 {
            public static final void main(String[] arg) {
                    String[] cmd={"top","-bn1"}; //,">","topf.txt"};
                    //String cmd="top -bn1 > topf.txt";
                    File topf = new File("topf.txt");
                    try {
                            FileWriter out = new FileWriter(topf);
                            Process p = Runtime.getRuntime().exec(cmd);
                            BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
                            String line;
                            String data22;
                            while ((line=in.readLine())!=null) {
                                    data22 = line;
                                    out.write(data22);
                                    out.write("\n");
                                    System.out.println(line);
                            out.close();
                            p.waitFor();
                    } catch (IOException e) {
                            e.printStackTrace();
                    } catch(InterruptedException e) {
                            e.printStackTrace();
    }

  • Problems with runtime.exec()

    Hi All,
    I am having a problem using runtime.exec()
    in servlet to call a java file from the server.The server is a linux one and i am using a tomcat server-4.1.24 the server contains
    some java files which i need to invoke with the help of the servlet program so i try to use exec() in servlet to invoke a particular java file in the server.The program is compiling well but no information
    is displayed on the browser.Where in the servlet program i try to print the details of the particular java program that is in the server.For ur
    reference i will post the code :-
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    public class ExeServlet extends HttpServlet
    public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
    try
    String path = getServletContext().getRealPath("/var/jakarta/webapps/examples/WEB-INF/classes/ServletExample.java");
    /*Where it is the path of the java file that resides in the server machine(linux)Which i want to invoke and print its details on the browser*/
    Runtime runtime=Runtime.getRuntime();
    Process proc=runtime.exec(path );
    BufferedReader br=new BufferedReader(new InputStreamReader(proc.getInputStream()));
    res.setContentType("text/html");
    PrintWriter pw=res.getWriter();
    pw.println("<b>");
    String line=null;
    while((line=br.readLine())!=null)
    { pw.println(line); //Displaying the details of the ServletExample.java file in the browser
    pw.println("</b>");
    catch (Exception e)
    pw.println("Listener *not* started!");
    What is the problem here?I was so frustrated with this.Pls. do provide an immediate reply if there is any code regarding this is working pls. do provide it.It is Urgent.I will be waiting for ur reply.
    Thanx,
    m.ananthu

    Hi Leo,
    Thank u for the reply i still have the problem with exec() in servlets.Has i said earlier in my previous mail by using exec() i trying to execute the output of a c-program for eg,Hello.run which provides an output of "HelloWorld" which is a sample eg.The Hello.run is the directory /var/jakarta/webapps/examples/WEB-INF/classes which is also the directory where my servlet program is.Where i am using a tomcat server-4.1.24 on the linux machine 7.3.Which is the server ofcourse.
    Here by using a servlet program i try to exceute the Hello.run c-program and display the output in the browser.This is what i need to do.
    I also used a sample core java class put the exec() there in a method and i try to call the method in the servlet.Which is also not working.
    Here is that example :-
    The core java program:-
    public class UsingExec
    public String ExeDisplay()
         try
    System.out.println("ExeDisplay");
         Runtime rt=Runtime.getRuntime();
         Process p=rt.exec("/var/jakarta/webapps/examples/WEB-INF/classes/Hello.run");
    p.waitFor();
    return "true";
         catch(Exception e)
    return "false";
    public static void main(String args[])
    UsingExec ue=new UsingExec();
    ue.ExeDisplay();
    When i run this program only ExeDisplay at the top is displayed.
    Here is the Servlet program:-
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    public class ExeServlet extends HttpServlet
    public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
    try
    res.setContentType("text/html");
    PrintWriter pw=res.getWriter();
    UsingExec ue=new UsingExec();
    String line=ue.ExeDisplay();
    pw.println(line);
    catch (Exception e)
    When i display this program on the browser only "false" is displayed from the UsingExec.java & nothing is displayed.
    Thanx,
    m.ananthu

  • Any problem with Runtime.exec()

    I am required to launch a local exe from an applet. At present I am using AppletContext.showDocument().The problem with this is that in netscape a box is popped up forcing the user to save that exe file. The requirwment is to run it directly without any message being asked.
    A workaround is to use Runtime.exec(), it works, however I have heard that it is not platform independent.
    (1) Is there a better solution than Runtime.exec() ?
    (2) If not could you give me some info on Runtime.exec() and the problems associated with it ?
    (3) Is there a way to use AppletContext.showDocument() without the message being asked ?
    Shikari.

    First of all, Java is platform independent language, and has many security restriction in it's applets.
    so from an applet you can't excute a program using "Runtime.getRuntime().exec()".
    coz. there is security restriction on that.
    for the "AppletContext.showDocument()" this methid is for displaying the specified document on the client browser, so it can't excute a client program.
    if u need to use Runtime.getRuntime().exec() you have to get the client agreement for that.
    see the applet security restriction for more info.

  • InputStream problem with Runtime.exec

    Dear all,
    I am writing a java application which is executing an external program (through threads). I am trying to read the output of that program while is in execution. Anyway i found out that InputStreamReader is not ready unless enough output of program is coming or the program exits.
    I simplified things writing the following small C program:
    main(){
    printf("Just a print\n");
    for(;;){} //Or anything that might keep program in execution
    So i am trying to find out why i cant get the output of this program unless it exits. Is this a problem with the underlying Stream? Is there any workaround?
    Thanks for any help.

    You are right. The C code is that of an external program that i am trying to execute and get its output. Actually i am working on a bigger program that it prints Directories recursively. To keep things simpler i used that simple C program to explain my problem.
    The code i am using is the following:
    /* WindowsExec.java */
    import java.io.*;
    public class WindowsExec
         response std_out,std_err;
         public WindowsExec(){
         try{
         String[] cmd = new String[]{"dark.exe"};
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(cmd);
    std_out = new response(proc.getInputStream(),System.out);          std_err = new response(proc.getErrorStream(),System.err);
    std_out.start();
         std_err.start();     
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
                   proc.destroy();
         } catch (Throwable t){
              t.printStackTrace();
    public static void main(String args[]){
              new WindowsExec();
    /* Response.java */
    import java.io.*;
    class response extends Thread
         InputStream is;
         PrintStream type;
         public response(InputStream is, PrintStream type){
              this.is = is;
              this.type = type;
         public void run(){
         try{
              InputStreamReader isr = new InputStreamReader(is);
    while(true){
    if(isr.ready()){
    System.out.println("Its ready!"); //HERE!!!
              break;     
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null){
    System.out.println(line);
                   isr.close();
                   is.close();
              catch (Exception ioe){
    ioe.printStackTrace();
    Notice that i am never getting isr.ready() = true!

  • Bdc upload file data into internal table problem with gui_upload fm

    Hello experts,
    my coding is like this ..
    data : begin of itab occurs 0 .
    field1 like mara-matnr,
    field2......
    etc,
    end of itab.
    data: file1 type string.
    parameter :file like rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    static = 'X'
    mask = space
    field_name = 'FILE'
    CHANGING
    file_name = file.
    START-OF-SELECTION.
    FILE1 = FILE . "HERE I AM PASSING INTO STRING
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = FILE1
    FILETYPE = 'ASC'
    has_field_separator = 'X'
    TABLES
    data_tab = itab. " here the data is not populating from the file , it is giving the error like speified table not found.
    HERE i am getting the message like "specified table name not recgonised" . the data is not populating into the itab from the file.
    file structure is same as the internal table.
    I stored the file as .txt( ie in notepad).
    my file is like this..
    10000 200 323 sunndarrr.......
    i had a problem with this bdc , i am getting like "specified table name not recgonised" in the fm gui_upload while debugging.
    when i am using the ws_upload it is working fine.
    please guide me where i have done the mistake.
    thank you so much for all the replies.

    Hi,
    Have a look on the following code.
    TABLES: kna1.
    DATA: BEGIN OF itab1 OCCURS 0,
          str(255),
          END OF itab1.
    DATA: itab2 TYPE kna1 OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                = 'D:\ABAP EVE\ffile1.txt'
        filetype                = 'ASC'
      TABLES
        data_tab                = itab1
      EXCEPTIONS
        conversion_error        = 1
        file_open_error         = 2
        file_read_error         = 3
        invalid_type            = 4
        no_batch                = 5
        unknown_error           = 6
        invalid_table_width     = 7
        gui_refuse_filetransfer = 8
        customer_error          = 9
        no_authority            = 10
        OTHERS                  = 11.
    IF sy-subrc <> 0.
      WRITE:/ 'sorry'.
    ELSE.
      LOOP AT itab1.
        SPLIT itab1-str AT ',' INTO itab2-kunnr itab2-name1.
        APPEND itab2.
      ENDLOOP.
      IF sy-subrc = 0.
        LOOP AT itab2.
          WRITE:/ itab2-kunnr,itab2-name1.
          INSERT INTO kna1 VALUES itab2.
        ENDLOOP.
        IF sy-subrc = 0.
          WRITE:/ 'inserted'.
        ELSE.
          WRITE:/ 'not inserted'.
        ENDIF.
      ELSE.
        WRITE:/ 'fail'.
      ENDIF.
    ENDIF.
    Flat file:
    10001,Sadney
    10003,Yogesh
    20005,Madan
    1.U need to define internal table with one field of max size
    2.upload the flat file data into that internal table
    3.split that internal table data into another internal table(having fields)
    <REMOVED BY MODERATOR>
    thanks,
    Chandu
    Edited by: Alvaro Tejada Galindo on Apr 30, 2008 12:17 PM

  • Interesting problem with XML data populating CFGRID

    Greetings all,
    I ran into an issue yesterday and I'm not sure how to resolve it.  I have an XML file I load to my MSSQL 2005 database, from there I populate my CFGRID with the fields from the database table, pretty straightforward right?
    It is until I realized the customer name appears to have a comma, so it looks like this:  Smith, John
    It appears Cold Fusion (cfGrid?) is looking at the comma as a delimeter and taking the value after the comma and putting it into the next column, basically shoving everything to the right.
    When I view the data in MSSQL Management Studio, it displays fine.  Does CF get the recordset from the database as a comma delimeted list?  Is this a known bug within CF?
    I need to fix it obviously but I'm not sure if it's easier to do it from within CF or when I load the XML file into the database.
    Any thoughts or guidance would be appreciated.

    It appears I have found my own solution...........ListChangeDelims and it works great.  It removed
    the comma from my text aligning everything correctly.

  • Newbie problem with "Runtime exec" "OutputStream"

    I am running an external process (Oracle Sqlplus) from a simple GUI using "Runtime exec". My problem is that I'm only able to retrieve input from the process after the Java output stream is closed. If I don't close the output stream my application does nothing. As soon as I close the output stream the input from the external process is printed to the screen and the external process is killed.
    I want to be able to start the external process once and then send and receive multiple input and output streams to it without having to stop and restart the process. Currently the only way to retrieve input from the process is to close the Java output stream which closes the process.
    Is this possible? Am I doing something wrong?
    I am new to Java so I appreciate your help.
    My code is below. I am running it on Windows 2000 Workstation, Java 1.4.1, Oracle 8.1.7.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    class ProcessTest extends JFrame implements ActionListener {
        private JTextArea upperTextArea;
        private JTextArea lowerTextArea;
        private BufferedReader in;
        private BufferedWriter out;
        public ProcessTest() {
            initialiseComponents();
            setBounds(200, 200, 600, 400);
            setVisible(true);
        public void initialiseComponents() {
            Container contentP = getContentPane();
            contentP.setLayout(new BorderLayout());
            upperTextArea = new JTextArea("SELECT SYSDATE FROM DUAL;\n");
            lowerTextArea = new JTextArea();
            JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                                                  new JScrollPane(upperTextArea),
                                                  new JScrollPane(lowerTextArea));
            splitPane.setDividerLocation(200);                                     
            JPanel buttonPanel = new JPanel();
            JButton runButton = new JButton("Start Process");
            runButton.addActionListener(this);
            JButton outputButton = new JButton("Write Output");
            outputButton.addActionListener(this);
            JButton flushButton = new JButton("Flush Output");
            flushButton.addActionListener(this);
            JButton closeOutputButton = new JButton("Close Output");
            closeOutputButton.addActionListener(this);
            JButton inputButton = new JButton("Read Input");
            inputButton.addActionListener(this);
            buttonPanel.add(runButton);
            buttonPanel.add(outputButton);
            buttonPanel.add(flushButton);
            buttonPanel.add(closeOutputButton);
            buttonPanel.add(inputButton);
            contentP.add(buttonPanel, BorderLayout.NORTH);
            contentP.add(splitPane, BorderLayout.CENTER);
        public void startProcess() {
            try {
                Process process = Runtime.getRuntime().exec("sqlplus -S " +
                                                             "scott/tiger");
                in = new BufferedReader(new InputStreamReader(
                                         process.getInputStream()));
                out = new BufferedWriter(new OutputStreamWriter(
                                          process.getOutputStream())); 
                System.out.println("Process Started.");                         
            catch(IOException e) {
                e.printStackTrace();
        public void writeOutput() {
            try {
                out.write(upperTextArea.getText().toCharArray());
                System.out.println("Output Write Completed.");
            catch (IOException e) {
                e.printStackTrace();
        public void flushOutput() {
            try {
                out.flush();
                System.out.println("Output Flush Completed.");
            catch (IOException e) {
                e.printStackTrace();
        public void closeOutput() {
            try {
                out.close();
                System.out.println("Output Close Completed.");
            catch (IOException e) {
                e.printStackTrace();
        public void readInput() {
            try {
                lowerTextArea.read(in, lowerTextArea);
                System.out.println("Input Read Completed.");
            catch (IOException e) {
                e.printStackTrace();
        public void actionPerformed(ActionEvent e) {
            String action = e.getActionCommand();
            if (action.equalsIgnoreCase("start process")) {
                Thread thread1 = new Thread(){
                    public void run(){
                        startProcess();
                thread1.start();
            else if (action.equalsIgnoreCase("write output")) {
                Thread thread2 = new Thread(){
                    public void run(){
                        writeOutput();
                thread2.start();
            else if (action.equalsIgnoreCase("flush output")) {
                Thread thread3 = new Thread(){
                    public void run(){
                        flushOutput();
                thread3.start();
            else if (action.equalsIgnoreCase("close output")) {
                Thread thread4 = new Thread(){
                    public void run(){
                        closeOutput();
                thread4.start();
            else if (action.equalsIgnoreCase("read input")) {
                Thread thread5 = new Thread(){
                    public void run(){
                    readInput();
                thread5.start();
        public static void main(String[] args) {
            new ProcessTest();
    }   

    At this point, I'm not getting the same results as you. I'm executing cmd.exe w/o args, and using the text area to do multiple directory listings in one go -- so far, the input thread has been able to keep up. Try copying & pasting the following below (I made a few changes to it). If it still doesn't work, it might help to know what operating system you're on, jdk version, etc..
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    class ProcessTest extends JFrame implements ActionListener {
        private BufferedReader in;
        private BufferedWriter out;
        private JTextArea upperTextArea;
        private JTextArea lowerTextArea;
        private ProcInThread pit;
        private class ProcInThread extends Thread {
            private BufferedReader in;
            private char[] cbuf = new char[8192];
            private int numRead;
            ProcInThread(BufferedReader in) {
                this.in = in;
            public void run() {
                Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
                do {
                    try {
                        numRead = in.read(cbuf, 0, cbuf.length);
                        if (numRead < 0) System.out.println("\n***END OF STREAM***\n"); // <-DEBUG CODE
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            lowerTextArea.append(new String(cbuf, 0, numRead));
                } while (numRead != -1);
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
        public ProcessTest() {
            initialiseComponents();
            setBounds(200, 200, 600, 400);
            setVisible(true);
        public void initialiseComponents() {
            Container contentP = getContentPane();
            contentP.setLayout(new BorderLayout());
            upperTextArea = new JTextArea("dir\ndir\ndir\ndir\ndir\ndir\ndir\n");
            lowerTextArea = new JTextArea();
            JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                                                  new JScrollPane(upperTextArea),
                                                  new JScrollPane(lowerTextArea));
            splitPane.setDividerLocation(200);
            JPanel buttonPanel = new JPanel();
            JButton runButton = new JButton("Start Process");
            runButton.addActionListener(this);
            JButton outputButton = new JButton("Write Output");
            outputButton.addActionListener(this);
            JButton flushButton = new JButton("Flush Output");
            flushButton.addActionListener(this);
            JButton closeOutputButton = new JButton("Close Output");
            closeOutputButton.addActionListener(this);
            JButton inputButton = new JButton("Read Input");
            inputButton.addActionListener(this);
            buttonPanel.add(runButton);
            buttonPanel.add(outputButton);
            buttonPanel.add(flushButton);
            buttonPanel.add(closeOutputButton);
            buttonPanel.add(inputButton);
            contentP.add(buttonPanel, BorderLayout.NORTH);
            contentP.add(splitPane, BorderLayout.CENTER);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        public void startProcess() {
            try {
                Process process = Runtime.getRuntime().exec("cmd.exe");
                in = new BufferedReader(new InputStreamReader(
                                         process.getInputStream()),8192);
                out = new BufferedWriter(new OutputStreamWriter(
                                          process.getOutputStream()),8192);
                pit = new ProcInThread(in);
                pit.start();
                System.out.println("Process Started.");
            catch(IOException e) {
                e.printStackTrace();
        public void writeOutput() {
            try {
                out.write(upperTextArea.getText().toCharArray());
                System.out.println("Output Write Completed.");
            catch (IOException e) {
                e.printStackTrace();
        public void flushOutput() {
            try {
                out.flush();
                System.out.println("Output Flush Completed.");
            catch (IOException e) {
                e.printStackTrace();
        public void closeOutput() {
            try {
                out.close();
                System.out.println("Output Close Completed.");
            catch (IOException e) {
                e.printStackTrace();
        public void readInput() {
        public void actionPerformed(ActionEvent e) {
            String action = e.getActionCommand();
            if (action.equalsIgnoreCase("start process")) {
                Thread thread1 = new Thread(){
                    public void run(){
                        startProcess();
                thread1.start();
            else if (action.equalsIgnoreCase("write output")) {
                Thread thread2 = new Thread(){
                    public void run(){
                        writeOutput();
                thread2.start();
            else if (action.equalsIgnoreCase("flush output")) {
                Thread thread3 = new Thread(){
                    public void run(){
                        flushOutput();
                thread3.start();
            else if (action.equalsIgnoreCase("close output")) {
                Thread thread4 = new Thread(){
                    public void run(){
                        closeOutput();
                thread4.start();
            else if (action.equalsIgnoreCase("read input")) {
                Thread thread5 = new Thread(){
                    public void run(){
                    readInput();
                thread5.start();
        public static void main(String[] args) {
            new ProcessTest();
    }

Maybe you are looking for

  • How to delete the row created by AddAnotherRow Button

    Hi Every one, We have a seeded page in Oracle Sales Opportunity Update. Here we have an activities region where we can add activities by clicking on AddAnotherRow Button. But there are no restriction of the row created in activities The issue we are

  • Is it possible to recover a single event in iPhoto with Time Machine?

    I was looking back through the events in iPhoto (300+), nd found one missing.  Not sure why; probably accidentally deleted.

  • Wondering how to create a text box with variables...

    Hi everyone, I was wondering how to create a text box, that at the beginning of the presentation, the audience fills in regarding what they think constitutes the role they have been chosen for. I would like that same box to then appear at the end of

  • Retrieve GOS Attachment

    Hi All, I am developing a program to retrieve the GOS attachment from PO attachment and send to the vendor through email. Kindly advise me to resolve this problem because I have no idea how to retrieve the attachment from the GOS table. Many thanks a

  • JS CS3-- User Interface Panels

    Hi all, Is it possible to change panels on a single window based on an onChange event? For example one onChange event will display a certain Panel and onChange will change it to a different panel on the same window? Regards Norbert