Invoking gdb through a Java program as subprocess

Hi,
I try to invoke the gdb through a java program using Runtime.exec(...)
as a Process, I also try to get the output of gdb using InputStream object, Is there any way to provide the options to gdb when it is started as Process & also tracing it's output.
please help Me.

Have a read of
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-
traps.htmlwhat ? I'm not sure what you are referring to with your 'what?' BUT that reference should be read by anyone using Runtime.exec().
>
the unix command such as
tail xxxxxxxxxxxxxxxxxx
and write it to a shell script,and invoke it by
java,any problems?I don't agree with this. There is no need for a shell script. This would just add to the complexity without adding any extra functionality.
>
but sabre150 has give a good solutionThank you.

Similar Messages

  • Running a Unix Script through a Java Program

    Hi !!!!!!!!! Can anybody plz suggest me an approach for the following queries -
    1.  How to execute a unix script through a java program ?
      2.  How to send the o/p of the script to a java program so that it can be used .

    import java.io.*;
    public RunScript
       public static void main(String args[])
          try
              Process p = Runtime.getRuntime().exec("script.sh");
              BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));     
              while ((line = input.readLine()) != null)
                 System.out.println(line);
              input.close();
          catch(Exception e)
              e.printStackTrace();

  • Is there any way to close an IE browser on XP through a Java Program

    Hi All,
    I am working on an application which has a web form with various feilds in it, on selecting the fields and clicking submit, the form will launch a WinRunner application in a remote machine and runs a test. For this I am using Tomcat webserver (V4.0.1). Now the problem I have is, when I submit the form, and WinRunner Launches on the remote machine (which has Operating System XP), should not already have any Browser windows open on it. So, to ensure that no browser windows are open, Initially in my Java Program I want to write a code which cleans up all the OPEN Browser windows on that machine.
    Can any one help me out in finding a way of closing the IE browser windows on a XP machine through a Java program. (There is a servlet in the Tomcat webserver which launches the application based on the browser request). Tomcat is installed on the machine where WinRunner will be launched, So my browser request goes to that machine directly.
    Thank you very much,
    Ramesh Babu M.V.

    You can call some program (via Runtime.exec) that kills all IEXPLORE.EXE processes (ugly but could work for you). For instance, there is a program called kill.exe that you can try getting somewhere. My version of KILL.EXE is really old and somewhat buggy (killed all IEXPLORE.EXE processes but one in my Windows 2003 machine), so try checking if there's some newer version anywhere.
    C:\>kill -?
    Microsoft (R) Windows NT (TM) Version 3.5 KILL
    Copyright (C) 1994-1998 Microsoft Corp. All rights reserved
    usage: KILL [options] <<pid> | <pattern>>*
               [options]:
                   -f     Force process kill
               <pid>
                  This is the process id for the task
                   to be killed.  Use TLIST to get a
                   valid pid
               <pattern>
                  The pattern can be a complete task
                  name or a regular expression pattern
                  to use as a match.  Kill matches the
                  supplied pattern against the task names
                  and the window titles.

  • How to implement a print screen through a java program rather than a keyboa

    help needed urgently to make a college project.
    have to capture whatsoever is on the client screen
    and sent it to to a server program where it will be made visible on a frame or panel.
    this is to be done without the client ever knowing it.
    so needed to implement a printscreen command using java code and put it in a program(also how to make
    the .class file containing this code run in the background all the time since the client comp starts till it is shut down without the client ever knowing it)
    e mail: [email protected]

    <pre>
    hartmut
    i need help.
    i've recently started using the web to learn more about java.your reply was very discouraging.
    the proff. just wants a decent project.
    but i want to make this project to improve my java networking skills.
    if you can help , please tell me how to implement a printscreen through a java program rather than a keyboard.
    I'll be very grateful to you if you can help me in this regard, but please dont send a dissapointing response like the previous one.
    mail: [email protected]
    </pre>

  • Unable to connect to Oracle 8i through a java program

    Hi all,
    I have Oracle 8i standard edition. Does this allow remote clients such as a java program trying to connect through a JDBC program?

    Yes, you should be able to connect to the Oracle database as long as you have your listener listening on a particular port, your JDBC URL has all the necessary info and you are using Oracle's JDBC driver.

  • Invoke.c from a java Program?

    Dear All,
    I have a java program that uses a DLL to invoke another jvm... this doesn't work and I was wondering if there was a way to do this? the code in the dll when put into a win32 console program works fine. but there is an exception when put into a DLL. Is it possible to have two jvm running?
    my code (psuedo)
    class HelloWorld
    public native void displayHelloWorld();
    static
    System.loadLibrary("HelloWorld");
    public static void main(String[] args)
    new HelloWorld().displayHelloWorld();
    #include <jni.h>
    #include "HelloWorld.h"
    #define PATH_SEPARATOR ';'
    #define USER_CLASSPATH "."
    JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject)
    // Code found in the invoke.c to call a class.
    }

    Thanks for your response.
    I'm programming a profiler using JVMPI. My profiler would be run:
    java -XrunProfiler HelloWorld
    the profiler would then, using JNI, display the info using java.
    is this really not possible?
    Cheers
    T

  • Running a perl shell command through a java program on linux platform

    i'm trying to execute the following command in a java program "perl xxx.pl" using the runtime.getruntime method
    here is the piece of code
    String[] cmd={"perl","-c","AraMorph.pl",""};
    Process p = Runtime.getRuntime().exec(cmd,null,new File("/home/ahmed/buckwalter_morphan_1/data"));
    p.waitFor();
    BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line=in.readLine())!=null)
    System.out.println(line);
    but it doesn't output anything even if i tried to print the output to a file
    i'm trying to execute this program on linux platform but its working properly on a windows platform
    thx
    raar

    String[] cmd={"perl","AraMorph.pl"," </home/ahmed/in.txt"," >/home/ahmed/ast.txt"};
    Process p = Runtime.getRuntime().exec(cmd,null,new File("/home/ahmed/buckwalter_morphan_1/data"));
    BufferedReader in=new BufferedReader(new InputStreamReader(p.getErrorStream()));
    String line;
    while ((line=in.readLine())!=null)
    System.out.println(line);
    p.waitFor();
    String str2=p.getInputStream().toString();
    System.out.println("==================================="+str2);
    and it still outputs nothing but goes in something like infinite loop or as assumed in the article u suggested a deadlock but even all solutions to all pitfalls didn't succeed

  • How to connect yahoo Api through a java program

    Dear All,
    I have problem in my java program. i have created two text field one is for username and another is for password.when we will give a yahoo id in one textfield and after that we will give the yahoo password in the other textfield. It will directly go to the yahoo server and collect all the friend lists which we have get in our program.please anybody tell me in this regards.
    Thanks and Regards
    Abhiram Sahoo.

    Which one? The one full of SPAM, my work address, or my one I use for my personal account?
    I think on my SPAM account, I'm down to less than 200 a day, I'll hve to go try to win that 54 inch Sharp Auquos again.

  • How to invoke dos shell from java program

    Hi,
    I'm not able to invoke dos shell from java.
    Can any one help me in this issue.
    I'm providing the source code below:
    try{
    Runtime.getRuntime().exec("cmd.exe")
    catch(IOException e) {
    System.out.println(e.getStackTrace());
    Thanks

    Does it throw a different exception?
    Or does it just do nothing at all?
    It does nothing at all[/b
    Is this a standalone Java app?
    Or a Java Applet running via a webbrowser? [b]It's a standalone application

  • How to invoke Netscape from a java program

    Hello
    In my Java program, I would like to launch a Netscape with one file as parameter in order to see the file with Netscape. Is there someone who can tell me how to do that, thanks.
    danfei

    System.getRuntime().exec("fullPathToNetscape/netscape parameter");

  • Invoking system utilities from java program

    Hi, I'm trying to write a program which will invoke system utilities when the user selects an appropriate option. The following code is a part of my app. But the problem is that I am not able invoke system utilities like chkdsk and disk defrag, which have specific exe's in system32 folder. I am able to invoke other exe's like Notepad.exe with the same code.
    import java.lang.*;
    public class Exec
    public static void main(String args[])
    try
    String [] st = {"C:\\WINDOWS\\system32\\chkdsk.exe"};
    Runtime var=Runtime.getRuntime();
    var.exec(st);
    catch(java.io.IOException e)
    Please tell me the problem and it's solution.

    Hi
    I am sending Class file .Call execute(String[] args) method in your class Exec file.
    it will print out put on screen .It works fine for me.
    I am using Windows NT .SO i used 'C:\\WINNT\\system32\\chkdsk.exe' execute command.
    Let me know any more infromation
    public class run {
         boolean flag = true;
         String message = "";
         String msg = "";
         String Error = "";
         Process p = null;
         public String execute(String[] args) {
                   try {
                        System.out.println("Please read it first here");
                        //run.getOutput(cmd,"call.txt");
                        StringBuffer sb = new StringBuffer();
                        StringBuffer sb1 = new StringBuffer();
                        p = Runtime.getRuntime().exec(args);
                        InputStream in = p.getInputStream();
                        InputStream in1 = p.getErrorStream();
                        int c;
                        while ((c = in.read()) != -1) {
                             //System.out.print("reached here---message ");
                             char ch = (char) c;
                             System.out.print(ch);
                             sb.append(ch);
                        System.out.println("Input String Buffer" + sb.toString());
                        msg = sb.toString();
                        int c1;
                        while ((c1 = in1.read()) != -1) {
                             flag = false;
                             //     System.out.println("reached here error ---message ");
                             char ch = (char) c1;
                             sb1.append(ch);
                        System.out.println("Error message is herr---" + sb1.toString());
                        Error = sb1.toString();
                        if(flag==false) message="EROOR :"+Error;else message="SUCCESS FULL:"+msg;
                        System.out.println("message value---"+message);                    
                   } catch (Exception ex) {
                        flag = false;
                        System.out.println("errror here" + ex);
                        return ex.getMessage();
                   System.out.println("message is here---" + message);
                   p.destroy();
              return message;
    Call
    public class Exec
    //import
    public static void main(String args[])
    try
    String [] st = {"C:\\WINNT\\system32\\chkdsk.exe"};
    System.out.println("Reached hefre ");
    run r=new run();
    r.execute(st);
    System.out.println("Reached after exect hefre ");
    catch(Exception e)
    System.out.println(" exception00---"+e);

  • Run a Program Through my java program

    Good day to you :)
    I am wondering if there is anyway for me to run an executable (or batch) file though a program I made.
    Thank you :)

    Found it. thanks anyway :)

  • How To Invoke A Command Prompt When I Run a Java Program ??

    Currently I want to invoke the Command Prompt(cmd)...through a JAVA PROGRAM....
    Can AnyOne tell me how to do it ???
    Thanx in advance.....

    hi,
    to be more specific, use the following, because you mention cmd i suppose you are using Windows NT
    so here goes
    String cmd[] = {"cmd.exe"};
    Runtime.getRuntime().exec(cmd);
    cheerz
    ynkrish

  • Accessing RUN through java programming

    Sir,
    i need to develop a java application t access "run" in start menu.How can i access the run menu through java programming.?I want to run the program in the run command when we input command through the java program..please help me..if you have the code palese send it tio me please..........

    But I cant access the drives for eg: I wrote c:\programfiles as input but i got an exception like this
    error=3
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
    at java.lang.Runtime.exec(Runtime.java:591)
    at java.lang.Runtime.exec(Runtime.java:429)
    at java.lang.Runtime.exec(Runtime.java:326)
    at ex.main(ex.java:10)
    how can correct this error...

  • Running OpenSSL command through Java Program

    How do I execute openssl commands through a java program? Any packages or wrapper classes are there? Please help.
    Thanks.

    Hi!
    What do you mean execute commands? Like: "openssl x509 -in cert.pem -out certout.pem" ??
    In that case you can just try the following:
    import java.lang.Runtime;
    try {
    Runtime.getRuntime().exec("openssl x509 -in cert.pem -out certout.pem");
    }catch (Exception e) {
    e.printStackTrace();
    ........

Maybe you are looking for