Problem to execute cvs command using Runtime.exec method

Hello,
I want execute this cvs command, with this options:
cvs -d :pserver:[email protected]:/home/cvs/cvsroot rlog -S -d "2007/05/01<now" Project
I tried to execute with Runtime.exec() :
Runtime.exec("cvs -d :pserver:[email protected]:/home/cvs/cvsroot rlog -S -d \"2007/05/01<now\" Project");
But I have an error because the smaller character is interpretate as a redirection, no as a smaller symbol.
How I can do to use this command with Runtime.exec ?
Thanks.
Regards.

Sorry,
I had a typing mistake.
I want say:
Runtime.exec("cvs -d :pserver:[email protected]:/home/cvs/cvsroot rlog -S -d \"2007/05/01<now\" Project");
Regards.

Similar Messages

  • Problem  in  executing dos command from runtime.exec(String command);

    Hi
    i have wriiten a code for running command of DOS-Promt
    try
         rnt1 = Runtime.getRuntime();
                                  proc1= rnt1.exec("myb");//myb is a batch file      and proc1 is process class instance
                                                                try
                                  proc1.waitFor();
                                  catch (InterruptedException e)
                             System.out.println("InterruptedException raised: "+e.getMessage());
                   catch (IOException ioe)
              System.out.println("IOException raised: "+ioe.getMessage());
    But it is giving error while running:
    this is showing as an IO exception
    CreateProcess: myb error=0
    Please help me how to proceed
    Thanks

    There are 2 possible reasons (perhaps concurrent):
    1. The file to be executed is not in the same path of your application, and you MUST specify its whole absolute path as exec() argument;
    2. The file to be execute is really (as you call it) a DOS batch file, and then it HAS TO BE NAMED (and called) myb.BAT or (under NT/2000) myb.CMD; WinDOS is Not Unix (WNU): extensions rule!!!

  • Problem while executing a command using exec()

    I'm trying to execute a command on Unix O/S with the help of java program. For this I have used Runtime class available in java.lang. It works fine for some of the basic unix commands like 'ls','cp' but when I tried to execute command "sqlldr userid=<user>/<pwd> control=/u01/dw/snb/log/sp_shd05721_ins_stg_sqlldr.ctl" , then it's not getting executed. Please advise.

    You may be having a problem with the command path, which I don't think Runtime.exec() uses. Try specifying the full path

  • Running System commands using Runtime.exec()

    I'm trying to run an example from "The Java Programming Language" book by Arnold, Gosling and Holmes. I'm trying to run a system level command and get the results. The code looks like:
    public static String[] runCommand(String cmd) {
    String[] outputData= null;
    String[] cmdArray = {"/usr/bin/ls", "-l", "/tmp"};
    try {
    Process child = Runtime.getRuntime().exec(cmdArray);
    InputStream in = child.getInputStream();
    InputStreamReader reader = new InputStreamReader(output);
    BufferedReader = new BufferedReader(reader);
    // read the commands output
    int counter = 0;
    String line;
    while ((line = input.readLine()) != null)
    outputData[counter++]= line;
    if (child.waitFor() != 0){  // error when it's not 0       
    System.out.println("Couldn't run the command.");
    System.out.println("It produced the following error message : " + child.exitValue());
    outputData = null;
    } catch (Exception e){
    System.out.println("It got here!");
    System.out.println("It produced the following error message : " + e.getMessage());
    outputData = null;
    return outputData;
    It gets to the while line, trys to run the input.readLine() and kicks out the exception that looks like:
    It got here!
    It produced the following error message : null
    I know it gets to the input.readLine() because I had a whole lot more try blocks in there, but for simplicity left it out (so it look like the code in the book, which I tried originally). When I run the same command from the command line (on our Sun Solaris 2.8 system) I get results back. I'm not sure what I'm doing wrong. Any help would be greatly appreciated. Thanks.

    Hi, duffymo, hope you can help me. Consider this servlet code:
    String theCommand = "csh /export/home/gls03/sasstuff/runsas.csh /export/home/g
    ls03/sasstuff/gary2.sas";
    //Create a parent Process for the sas program subprocess:
    Process p = rt.exec(theCommand);
    System.out.println("after call to rt.exec(theCommand)");
    Here is the runsas.csh script:
    #!/bin/csh
    setenv LD_LIBRARY_PATH /opt/sybase/lib:/usr/lib:/usr/openwin/lib:/opt/SUNWspro/S
    C2.0.1
    setenv SASROOT /usr/local/CDC/SAS_8.2
    setenv XKEYSYMDB /usr/local/CDC/SAS_8.2/X11/resource_files/XKeysymDB
    $SASROOT/sas -sasuser /hpnpages/cgi-bin/applinks/hospcap/tmp $1
    The execution never gets to the println statment, here is the error:
    class java.io.IOException Exception. Message: CreateProcess: csh /export/home/g
    ls03/sasstuff/runsas.csh /export/home/gls03/sasstuff/gary2.sas error=2
    java.io.IOException: CreateProcess: csh /export/home/gls03/sasstuff/runsas.csh /
    export/home/gls03/sasstuff/gary2.sas error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Win32Process.java:66)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:551)
    at java.lang.Runtime.exec(Runtime.java:477)
    at java.lang.Runtime.exec(Runtime.java:443)
    at sasRunnerNew.doPost(sasRunnerNew.java:103)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:262)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:21)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
    va:27)
    at us.ny.state.health.hin.hinutil.HinFilter.doFilter(HinFilter.java:124)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
    va:27)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
    rvletContext.java:2643)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
    pl.java:2359)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    The command runs fine in unix.
    I've also tried using these as arguments to exec:
    String theCommand = "/bin/csh /export/home/gls03/sasstuff/runsas.csh /export/home/gls03/sasstuff/gary2.sas";
    String[] theCommand = {"csh", "/export/home/gls03/sasstuff/runsas.csh", "/export/home/gls03/sasstuff/gary2.sas"};
    These generate the same error. I'm thinking this is a sas-specific problem.
    Thanks for any help. Gary

  • Executing a command using Runtime Class

    How to execute a command on a differnet machine with different ipaddress using Runtime Class
    My code is
    String[] cmd = new String[3];
    cmd[0] = "192.1...../c:/WINNT/system32/cmd.exe" ;
    cmd[1] = "/C" ;
    cmd[2] = args[0];
    Runtime rt = Runtime.getRuntime();
    System.out.println("Execing " + cmd[0] + " " + cmd[1]
    + " " + cmd[2]);
    Process proc = rt.exec(cmd);
    // any error???
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
    This is not Working

    I have same issue. Actually when I use cmd.exe /c set in java code and if I run the java code in DOS propmt, it retrieves all latest user Environment variable values. But if I run the code in windows batch file, it is not retrieveing the latest user environment values until I reboot my computer, Do you know how to get user environment value with out rebooting machine??????

  • Problem in running system commands using Runtime()

    hi,
    i am trying to run the "dir" command in windows OS using Runtime(). But while
    executing the program i am getting
    java.io.IOException: CreateProcess: dir error=2 error. But if i replace the "dir" command by "notepad" command its working fine. below is the source code.
    class testing
    public static void main(String args[])
         try{
    Runtime rt=Runtime.getRuntime();
    Process p=rt.exec("dir"); //Generating Errors
    //Process p=rt.exec("notepad"); //Working Fine
         }catch(Exception e){System.out.println(e);}
    }plzz help me out.
    thanx

    thats fine its working. i made two changes. First i used an array to send the
    arguments. if we directly use "cmd.exe /c dir" then its converting "/C" to "\C" thus
    producing the error. so i used
    Runtime rt=Runtime.getRuntime();
    String args1[]={"cmd.exe","/C","dir"};
    Process p=rt.exec(args1);But then i got no error no output. From other forums i came to know about capturing the data using input streams and i included the following code.
    BufferedReader Resultset = new BufferedReader
         (new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = Resultset.readLine()) != null)
         {          System.out.println(line);          }Now its working fine. Thanx for ur help.

  • Using Runtime exec() method to run java files and return runtime errors

    Hi
    I'm writing a java editor and I use
    Runtime.getRuntime().exec(command)
    to compile the java files. That works fine and I deal with the returned errors using the getErrorStream().
    My questions are:
    1. Can I use the same technique for returning runtime errors. In any posts I've read the process runs from begining to end, returning the errors after completion. How do I return the errors of the app as they happen interactively?
    2. If i cant use the exec and getErrorStream() methods then does anyone know how it is done?
    Thanks in advance for any help!

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

  • Spawn a java process using runtime.exec() method

    Hi,
    This is my first post in this forum. I have a small problem. I am trying to spawn a java process using Runtime.getRuntime().exec() method in Solaris. However, there is no result in this check the follwoing program.
    /* Program Starts here */
    import java.io.*;
    public class Test {
    public static void main(String args[]) {
    String cmd[] = {"java", "-version"};
    Runtime runtime = Runtime.getRuntime();
    try{
    Process proc = runtime.exec(cmd);
    }catch(Exception ioException){
    ioException.printStackTrace();
    /* Program ends here */
    There is neither any exception nor any result.
    The result I am expecting is it should print the following:
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
    Please help me out in this regard
    Thanks in advance
    Chotu.

    Yes your right. It is proc.getInputStream() or proc.getErrorStream(). That is what I get for trying to use my memory instead of looking it up. Though hopefully the OP would have seen the return type of the other methods and figured it out.

  • Problem wiht Running Batch File using Runtime.exec()

    I am writting one program which will create a jar file using a windows Batch file.
    The main program is in the folder "d:\CmdExec.java".
    The other one to which a jar file to be created is in the folder "e:\folder\HelloWorld.class"
    The contents inside the "e:\folder" are
    e:\folder\HelloWorld.class
    e:\folder\mainClass.txt
    e:\folder\run.bat
    The mainClass.txt contains "Main-Class: HelloWorld"
    The Run.bat file contains "jar cmf mainClass.txt HelloWorld.jar *.class"
    The coding for CmdExec.java is as follows
    import java.io.*;
    import java.awt.Desktop;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
    Desktop desktop = null;
    if (Desktop.isDesktopSupported()) {
    desktop = Desktop.getDesktop();
    desktop.open(new File("e:\\folder\\run.bat"));
    catch (Exception err) {
    err.printStackTrace();
    When i double click the file e:\folder\Run.bat, it will create a jar file for HelloWorld.class.
    But, i want to create that jar file using the java program CmdExec.java.
    When i run CmdExec.java, the batch file is opened. But it shows error as "Can't find the specified file"
    But when i copy the following files to "d:\",
    e:\folder\HelloWorld.class
    e:\folder\mainClass.txt
    the jar file is created using the CmdExec.java.
    But,
    e:\folder\HelloWorld.class
    e:\folder\mainClass.txt
    these files should be in the folder"e:\folder" only.
    Can anyone Help me this Problem?
    Or Anyother way for creating a jar file for one program by using another program?
    Help me soon.............

    Try this. It's not running a bat file. You can say it almost is a bat file.
    import java.io.*;
    import java.util.Scanner;
    public class CmdExec {
        public static void main(String argv[]) {
            try {
                Process p = Runtime.getRuntime().exec("jar cmf mainClass.txt HelloWorld.jar *.class");
                Scanner s1=new Scanner(new InputStreamReader(p.getInputStream()));
                while(s1.hasNextLine())
                    System.out.println(s1.nextLine());
                p.waitFor();
                System.out.println(p.exitValue());
                if(p.exitValue()==0)
                    System.out.println("Okay");
                else
                    System.out.println("Error");
            catch (Exception ex) {
                ex.printStackTrace();
    }Run it in the same folder as mainClass.txt
    Edited by: ColacX on Aug 1, 2008 10:35 AM

  • Problem with executing SPARQL command using jdbc or jena in Java

    Hi everybody
    I am new to Oracle and SPARQL, so I'm sorry if my question is the elementry one!
    select s, p, o  from table(SEM_MATCH( '(?s ?p ?o) (?s <htt...> ?o) ', SEM_Models('OWlTEST'), null, null, null ))
    I have an SPARQL command which runs on Oracle correctly and returns 8 Rows. So far so good!
    I tried two ways to use this command in java code:
    Using java.sql.jdbc
    stmt = conn.createStatement();
    rs = stmt.executeQuery(...the whole command above ....);
    if (rs.next()){
    System.out.println(rs.getString("O"));
    Problem: resultset returns only One row, which is the first row, althogh in debug mode I can see validRow=8!!!
    Using com.hp.hpl.jena
    Model model = ModelFactory.createDefaultModel();
    String queryStr = "PREFIX : <.....> SELECT ?s ?p ?o  FROM  <...> WHERE {?s prefix:property ?o}";
    Query query = QueryFactory.create(queryStr);
    QueryExecution qexec = QueryExecutionFactory.create(query, model);
    com.hp.hpl.jena.query.ResultSet results = qexec.execSelect();
    for (;results.hasNext();) {
    Problem: it returns nothing!!
    Do you any Idea,
    Thanks in advance
    Sara

    Sara,
    I don't know about SPARQL not about jena, but for Java you need to change:
    {code}
    if (rs.next()) {..
    {code}
    to
    {code}
    while (rs.next()) {..
    {code}
    Otherwise you just fech and see only first row.
    Look at : http://www.java2s.com/Code/JavaAPI/java.sql/ResultSetnext.htm
    HTH
    Thomas

  • Running MS-DOS commands using Runtime.exec()

    Is there any way to run the dos commands like copy and del from our java program? Actually I want to implement a visual console kind of thing and have to transfer the commands to the prompt and get the result string that is to be displayed in a JTextArea?
    Please help me. It'll be very nice of you...thanks

    I can help you in two ways:
    o by telling you to run cmd.exe and pass the rest as parameters.
    o by pointing out this is the wrong forum for you equestion.

  • Executing bat file without using Runtime.exec()??

    Hi all
    From my java App ,I am running a bat file. This is what I did:
    When I press 'execute' button inside my App, it runs a bat file through Runtime.exec() method. Since exec() runs it through cmd.exe, get a DOS window when I press Execute button. If I manually runs my app from command promt , I dont get it. But I have to create a short cut of my main class in the desktop. This is happening when I run my app from desktop icon.
    Now I want to eleminate DOS popup everytime I press execute button. Would anyone pls give an idea how to run bat file without using Runtime.exec()? Any suggestion will be helpful.
    Thanks

    jscell
    Thanks for taking time to answer to my problem .
    Here is what my problem: I create a shortcut of my main class in the desktop. Through this shortcut ,I run my java App. My App has a execute button, When I press this button , It run another bat file through Runtime.exec() method, and show some result in the result PAnel. NOw what happen , I get a DOS command window , everytime I press execute button. , Which is very annoying . But If I run my App thorugh command promt by executing: "java myApp", then I dont get this DOS popup. But I have to create a shortcut in the desktop, so other can use it conveniently.
    NOw I am not sure why I am getting this DOS window in the middle of my Application. IS it for using Runtime.exec() method? or for running bat file through my application? Can anyone pls tell me? I am kind of new to java, and I am learning lot of stuff from this forum .
    Would u pls suggest me about how to eleminate this DOS popup when I press execute button.
    Regrds

  • Running ssh in xterm using Runtime.exec !! URGENT

    I am not able to run the following command using Runtime.exec() but if the same command is executed in shell it gets executed.
    I am working on solais 8
    String toExecStr =
    "xterm -e /bin/sh -c \"ssh [email protected] || echo SSH failed. Press any key to quit.; read a \"";
    System.out.println("Running command :" + toExecStr);
    try {
    Process p = Runtime.getRuntime().exec(toExecStr);
    catch(Exception e){
    e.printStackTrace();
    Any clues .. am i missing something Is there some problem with solaris command ..

    Can some body help me solve this ???

  • Problem of executing a process under Linux using Runtime.exec

    Hi, All
    I am having a problem of executing a process under Linux and looking for help.
    I have a simple C program, which just opens a listening port, accept connection request and receive data. What I did is:
    1. I create a script to start this C program
    2. I write a simple java application using Runtime.exec to execute this script
    I can see this C program is started, and it is doing what it supposed to do, opening a listening port, accepting connection request from client and receiving data from client. But if I stop the Java application, then this C program will die when any incoming data or connection request happens. There is nothing wrong with the C program and the script, because if I manually execute this script, everying works fine.
    I am using jre1.4.2_07 and running under Linux fedora 3.0.
    Then I tried similar thing under Windows XP with service pack2, evrything works OK, the C program doesn't die at all.

    Mind reading is not an exact science but I bet that you are not processing either the process stdout or the stderr stream properly. Have you read http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html ?

  • Problem in using runtime.exec()

    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

    Is it possible that this is a re-post of this thread?
    http://forum.java.sun.com/thread.jspa?threadID=636637
    :^)Might be! What gives you that impression?

Maybe you are looking for

  • How to install 32 bit program with 16 bit installer on Windows 8.1 32 bit

    Hi, I have installed a 32 bit program that uses a 16 bit installer on Windows XP machines.  The software developer of this program is out of business. Can Windows 8.1 32 bit run a 16 bit installer?  If not, any suggestions as to how I might install t

  • HT4865 how to register my ipad mini?

    how to register ipad mini

  • Rendering Video from PS CS4

    Ive got some footage shot from my Canon T2i (1080p @ 30fps) that ive edited the levels in to adjust the color. When I go to export it in Apple Pro Res 422 it works fine, the only problem is the file is MASSIVE. Ive got a 9 second clip that renders ou

  • ITunes does not show album artwork for FLAC files

    I add FLAC music files to iTunes via Fluke which works perfectly. Then I add the album artworks to the albums as usual (select all songs/right click/get info/info/then drag and drop a previously downloaded .jpg file). The artwork is visible in the Ar

  • Garageband 412 update

    ive got about eight months worth of recording done, about nine songs, finished, and im not sure if i should update to the 412 version. is there any risk of having these songs changed, deleted, or not running properly if i do the update?ive read some