Run Clear Case command from java and save the out put in to a file.

Can any one help me out ...
I want to execute Clear case command from a java and want to save the out put of this command to a file.
I am naot able to find out how to start..
Message was edited by:
chandra_verma

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Similar Messages

  • Running OpenVMS DCL command from Java

    Hi,
    I want to execute an Alpha OpenVMS 7.2-2 command from Java. I use JDK 1.1.8-1.
    I have to place the DCL command in an OpenVMS .COM file because passing a DCL
    image like DIR doesn't work using Runtime.exec().
    When I ran the Java program, I get the following error:
    java.io.IOException: Child creation error: exec format error
    at java.lang.UNIXProcess.<init>(Compiled Code)
    at java.lang.Runtime.exec(Compiled Code)
    at java.lang.Runtime.exec(Compiled Code)
    at oscmd.main(Compiled Code)
    here is my Java program:
    import java.io.*;
    public class oscmd {
    public static void main(String[] args) throws Exception {
    Process child = Runtime.getRuntime().exec(
    "dra1:[oracle8.db_adamp.backup]RUNCMD.COM");
    child.waitFor();
    child.exitValue();
    child.destroy();
    Thanks for your help.

    Hi,
    Did you get your exec format error problem?
    I'm having exactly the same problem and would greatly appreciate any help you could offer.
    Thanks
    Tim

  • I want to run a vi for 4 days and save 360,000,000 samples in a file

    Hi
    I want to run a vi for 4 days and save samples to a file.
    I use the Ni EX save to file.vi example provided by LabView and change the Trigger mode to "immidiate ref trigger" as I am measuring a DC voltage.
    The application runs correctly when min record length is 2048 however when I change the min record length to 2,000,000 I receive the following error message and nothing get saved:
    Error occurred at:  niScope Multi Fetch.vi
    <err>Driver Status:  (Hex 0xBFFA2003)
    Maximum time exceeded before the operation completed.
    Possibly no trigger received. Buffers done: 0, Points done: 0.000000.
    I appreciate if you help me in this regard,
    Maryam

    Maryam,
    Have you tried increasing the timeout?  What is the exact name of the vi that you are using. Also, what hardware are you using?  What driver versions do you have installed?  Actually, the more information you could give us, the better.  Thanks and have a great day!
    Regards,
    Lon A.

  • Running ssh command from java and then answering password prompt

    Hi,
    I have a situation that has not solved yet. I am running ssh command from unix terminal without any problem, and then i enter password.
    For example :
    [oracle@fuata]:/export/home/oracle> ssh -N [email protected] -L 9901:127.0.0.1:9999
    Password:
    It is working. I have question that how can i perform this in java? I am thinking that i can run ssh command by using Runtime Class, it is ok. But how can i answer the password? I am a bit confused. Is there any example looks like this?
    Thanks for responses.

    futi wrote:
    Thanx. Firstly i insisted to do this without jsch but actually this is harder than jsch. I edit some of code pieces PortForwardingL.java and could run it. It works problem-free. Could you say why you "insisted" on this approach. It can't be for speed+ since jsch is very fast. It can't be for portability+ since jsch is portable but the use of Runtime.exec() requires the installation of ssh software. It can't be because of limitations+ since jsch is a fully featured library. It can't be for security+ since jsch is secure. It can't be for ease of use+ since jsch is much easier to use than ssh with Runtime.exec(). Unless it's a licensing issue, it can't be for commercial+ reasons since jsch is free. The only reason I can think of why one would "insisted" on this approach is if it is for some college project.

  • Running Interactive commands in java and displaying the output.

    Hi All,
    I'm running a sample code to execute a user defined command (cmd1) and display the results. The output of the command when executed in command prompt is
    (1) Executing the command cmd1
    (2) Do you want to continue(Y/N)_ <waits for user input>
    (3) Based on user input
    (Y) Displays the results
    (N) Interrupted
    But i'm facing problem when i execute the below code. When the results are being displayed instead of displaying line(1) and (2) and then waiting for the input- the code waits for the input and then only displays the results.
    O/p
    inside output
    inside input
    y (------ gets the input and then only displays the results).
    Executing the command cmd1
    Do you want to continue(Y/N)
    results
    Please help out how to resolve this issue.
    Thanks.
    Sample Code for reference.
    import java.util.*;
    import java.io.*;
    public class SampleCheck {
         public static void main(String[] args) throws Exception {
              (new SampleCheck()).test();
         void test() throws Exception {
              Process proc = Runtime.getRuntime().exec("cmd1");
              // any error from the process?
              StreamHandlerErr errorStream = new StreamHandlerErr(proc
                        .getErrorStream(), System.err);
              // any output from the process?
              StreamHandlerOutput outputStream = new StreamHandlerOutput(proc
                        .getInputStream(), null);
              // any input to the process?
              // FileInputStream fin = new FileInputStream(new File("textfile1.txt"));
              StreamHandlerInput inputStream = new StreamHandlerInput(System.in, proc
                        .getOutputStream());
              // start the stream threads
              // errorStream.start();
              outputStream.start();
              inputStream.start();
              // wait till it returns
              int exitVal = proc.waitFor();
              System.exit(exitVal);
         class StreamHandlerInput extends Thread {
              InputStream is;
              OutputStream os;
              StreamHandlerInput(InputStream is, OutputStream os) {
                   this.is = is;
                   this.os = os;
              public void run() {
                   System.out.println("inside input");
                   try {
                        int c;
                        while ((c = is.read()) != -1) {
                             os.write(c);
                             System.out.println("c= " + c);
                             os.flush();
                   } catch (IOException e) {
                   System.out.println("End of Run Method..Input");
         class StreamHandlerOutput extends Thread {
              InputStream is;
              OutputStream os;
              File f=new File("jbsrt_output.txt");
              StreamHandlerOutput(InputStream is, OutputStream os) {
                   this.is = is;
                   this.os = os;
              public void run() {
                   System.out.println("inside output");
                   try {
                        int c;
                        FileOutputStream fs=new FileOutputStream(f);
                        /*PrintStream ps =new PrintStream(;
                        ps.print(arg0)
                        ps.close();*/
                        InputStreamReader ir = new InputStreamReader(is);
                        //System.out.println(ir.read());
                        BufferedReader br = new BufferedReader(ir);
                        String line = null;
                        while((line=br.readLine())!=null)
                             System.out.println(line);
                   } catch (Exception e) {
                   System.out.println("End of Run Method..Output");
         class StreamHandlerErr extends Thread {
              InputStream is;
              OutputStream os;
              StreamHandlerErr(InputStream is, OutputStream os) {
                   this.is = is;
                   this.os = os;
              public void run() {
                   System.out.println("inside Err");
                   try {
                        int c;
                        while ((c = is.read()) != -1) {
                             os.write(c);
                             os.flush();
                   } catch (IOException e) {
                   System.out.println("End of Run Method..Err");
    }

    Console input is line buffered. This means you only get the first character a line after the newline has been inputed.
    The same thing happen if you just type on the console.
    I am not aware of any simple way around this.
    IDEs get around this by changing the application run so that the input/output is captured as it happens and sent over a socket connection.

  • Efficiently Running UNIX des command from Java

    Hi,
    I am trying to execute the following code in a loop to have an Brute Force attack for recovering the key.
    Runtime r = Runtime.getRuntime();
    p = r.exec("des -D -k "+keys.get(randomIndex)+ " " +cipherTextFileName);
    But as the des command has to read the file every time the programm is not a efficient one.Can I do something like reading the ciphertext from the file only once and then pass it to the des command from the java.So that it won't do I/O operations resulting good performamnce.If I can do this how to do it.Please suggest with examples.
    Thanks
    Tapas

    If you use Java you're not doing that. What does being an Academic project have to do with what tools you're allowed to use? Who is dictating that you're "only" allowed to use the des command line tool? (If it comes to that, which des command line tool are you using anyway? It's not a unix standard thing).
    The one thing you can do is to see if there is an option to read the file(s) from standard input and send them to the process from the Java runtime that way - that way the input doesn't have to be read multiple times. However this is unlikely to make any significant difference. Most of the performance cost is likely to be the context switch required to kick off the new process with very little cost incurred from re-reading a file from the disk cache.
    You've got your answer anyway. You're not going to be able to make this much more efficient. I recommend not doing that. If you really really have to, well, tough.

  • How can I run a dos command from java on windows 98, 95?

    The usage of cmd.exe in the java program to run a dos command on windows 98. 95 doesn't work as the equivalent command is command.exe
    But using the command.exe in the java program makes my program to hang.

    hi,
    As u mentioned, u cannot use the cmd.exe in win9x environment as cmd.exe is specific to windows NT, you can use the command.exe without any hitches.
    for eg
    java.lang.Runtime.getRuntime().exec("start command /K a.bat"); should run the batch file a.bat..
    if the problem persists, try posting the snippet of code that you are using.
    cheerz
    ynkrish

  • Executing sqlldr (sql loader) from java and returning the error code

    I'm wandering do sqlldr return any error code whenever it hit error while running in java.
    For example, if i run in command prompt using the command below,
    C:\ >sqlldr uid/pwd data=abc.dat control=abc.txt
    It might give me some indicator that error occurs such as
    SQL*Loader-601: For INSERT option, table must be empty. Error on table CURRENCY
    or
    SQL*Loader-500: Unable to open file (abc.txt)
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: The system cannot find the file specified.
    But when i run in java using the code below,
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("sqlldr uid/pwd data=abc.dat control=abc.txt");
    int exitVal = proc.waitFor();
    System.out.println("Process exitValue: " + exitVal);
    it will only give me the same exitValue of 1(i presume its error) / 0 (i presume no error) instead of the details of the error.
    How can i get the exact error code/message if i were to execute it using java?
    Any solution?

    mg,
    I don't think user576271 wants the exit code, I think [s]he wants the error message.
    But wouldn't error messages from SQL*Loader be sent to the stderr stream, and not the stdout stream?
    In which case user576271 would need method "getErrorStream()" of class java.lang.Process, no?
    Good Luck,
    Avi.

  • Execute the command "arp -a" and save the list of ip & MAC adresses

    Hey all ,
    I was looking for a code where i can execute the command "arp -a" in CMD to get a list of all MAC and ip adresses
    connected on the network and save them for further use is this possible or not .. please if possible if any 1 can supply me with the code i would be grateful ... thnks for ur time
    Best Regards,
    MIG()ZZZZ

    the list of ip and mac of connected computers to the networkThere really isn't a way of doing this because in TCP/IP 'connected' doesn't have a well-defined meaning, so there is no such thing as 'the list' either. If it's a Windows LAN you might find something in Samba that will do it, I don't know.
    What's it all for? There are also IP broadcast and multicast facilities, could be what you're really looking for.

  • How do I download and save the user manual as a pdf file?

    where is the "divice manual icon ???
    >> Branched from an earlier discussion <<
    Message was edited by: Verizon Moderator

    Go to this link:
    Samsung Galaxy S III 16GB in Black Support | Verizon Wireless
    and look under the Get to Know Your Device section.  Click the Device Manual button and let the manual download.  Once it's done, use your browser's save feature to save the file to your computer.

  • Importing log4j.xml and viewing the out put .

    hi iam having log4j.xml which i should use to view the output .iam using netbeans IDE .i imported import org.apache.log4j.Logger; then i added log4j.xml in source package .and apache log4j to the libraries .
    *.but how to import this log4j.xml file and view the output?*
    import java.util.logging.Level;
    import org.apache.log4j.Logger;
    static Logger logger = Logger.getLogger( Header.class);the how to use * logger* to view ConsoleAppender and PatternLayout

    Open a text editor. Go to the File menu and select the Open option. Navigate to the directory where the log4j.xml file is located. Select it and it will appear in your text editor, where you will be able to view it.
    That wasn't what you meant, was it? Unfortunately I can't understand what you do mean. You seem to be confusing the act of writing a program which will write output to a file with the act of looking at that file. And you seem to be confusing Java programming operations ("import") with something else that I don't understand.
    Could you rephrase your question and perhaps include something that explains what you want to do? Because you have it backwards. Loggers don't view files, viewing is reading. Loggers write files.

  • Issues with running UNIX shell command from Java

    Here is my java class file:
    create or replace and compile java source named host as
    import java.lang.* ;
    public class Host
       public static void cmdTest()
            String cmd = "ps -ef | grep orcl" ;
            int rc = 0 ;
            int = runCmd(cmd) ;
       public static int runCmd(String str )
           Runtime rt = Runtime.getRuntime() ;
           int     rc = -1 ;
          try
                Process p = rt.exec(str) ;
                int bufSize = 4096 ;
                BufferedInputStream bis =
                    new BufferedInputStream(p.getInputStream(), bufSize) ;
                int len ;
                byte buffer[] = new byte[bufSize] ;
                // Log what the program spit out
                while ((len = bis.read(buffer, 0, bufSize)) != -1)
                    rc = p.waitFor() ;
            catch (Exception e)
                e.printStackTrace();
                rc = -1 ;
            finally
                return rc ;
    show errorsI can call runCmd directly from SQLPlus using an Oracle stored procedure and it runs like expected. I can see the returned output using dbms_java.set_output(1000000).
    But when I call cmdTest from SQLPlus using an Oracle stored procecdure it just hangs forever and I have to kill the session.
    Is there something I am missing in the cmdTest method?

    Jimmy,
    If you haven't already seen it, I think the following article may be of help:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Also a "finally" block should not contain a "return" statement:
    http://weblogs.java.net/blog/staufferjames/archive/2007/06/_dont_return_in.html
    Good Luck,
    Avi.

  • Running a db2 command from Java Application ??

    Hi All,
    I have to write an application in JDBC that can retrieve a list of databases on a db2 server, the only way I know is the db2 command "list database directory", but I can not use it in a JAVA program, is there a solution for this?
    Can anyone help me in this regard ?
    Thanks in Advance.

    If your driver implement it you can list databases with DatabaseMetaData
    Connection conn = ...
    DatabaseMetaData meta = conn.getMetaData();
    ResultSet rs = meta.getCatalogs();
    while (rs.next())
        System.out.println(rs.getString("TABLE_CAT"));
    }

  • Running a SQL*Plus command from Java

    I have a requirement to run SQL* Plus commands from Java. The results as they would appear in SQL*Plus window or spool file should be captured and stored in a table.
    For example,
    SQL> select * from dual;
    D
    X
    1 row selected;
    SQL>
    All the lines above should be stored for later use.
    Could any one give pointers?
    Thanks,
    Ravi

    <p>
    Hi,
    </p>
    <p>
    <strong><font face="Courier New">
    public class RuntimeExecApp {
     public static void main(String args[]) throws IOException
      Runtime r = Runtime.getRuntime();
      r.exec(&quot;C:\\Oracle\\sqlplus.exe&quot;);
    }</font></strong>
    </p>
    <p>
    Kuba 
    </p>
    Message was edited by:
    KUBA

  • How to run system commands from JAVA

    Hi Friends,
    How to run windows system commands from JAVA
    Runtime r=Runtime.getRuntime();
    r.exec("dir");
    Throwing following Exception
    CreateProcess :dir error=2
    Thanks in advance
    Hamsa

    Hi ,
    in Windows NT this is not possible, you can use the following :
    Runtime r=Runtime.getRuntime();
    StringBuffer sbuf = new StringBuffer();
    String dir = new String();
    java.lang.Process proc = r.exec("cmd /c dir");
    InputStream is = proc.getInputStream();
    int ch ;
    while((ch=is.read() ) != -1)
    sbuf.append((char)ch);
    is.close();
    dir = sbuf.toString();
    System.out.println(dir );

Maybe you are looking for