Results 1 to 5 of 5
  1. #1
    Brad is offline Member
    Join Date
    Feb 2012
    Posts
    21
    Rep Power
    0

    Default Problem using Swing to create a Subversion dump file

    I am trying to back up a Subversion repository with a little Java Swing app that I wrote.

    I have a string that hold the command:

    Java Code:
    String full = svnrdump_exe + " dump --username " +username+ " --password " +password + " --quiet " +source+ " > " +destination;
    When I print this line to the console it looks correct. Here is an example of the output:

    "C:\\Program Files\\TortoiseSVN\\bin\\svnrdump.exe" dump --username Me --password myPassword --quiet https://lnsvr0005/data/swreuse > "C:\\Temp\\backup.dump"

    I can copy the output to a command prompt and run it successfully.

    I tried adding cmd /c at the beginning of the string and that didn't seem to make a difference either.

    The error is "Type 'svnrdump.exe help' for usage.". So I think Java is parsing the string incorrectly somewhere. Do I need to escape the -- or the / in the string?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: Problem using Swing to create a Subversion dump file

    You're using IO redirection '>' so you should definetely pass the string to a shell (cmd /c). Maybe there was an error there in your composed string ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Brad is offline Member
    Join Date
    Feb 2012
    Posts
    21
    Rep Power
    0

    Default Re: Problem using Swing to create a Subversion dump file

    I added cmd /c and I am still not having any luck. Here is the new string:

    String full = "cmd /c " + svnrdump_exe + " dump --username " +username+ " --password " +password + " --quiet " +source+ " > " +destination;

    Output:
    cmd /c "C:\\Program Files\\TortoiseSVN\\bin\\svnrdump.exe" dump --username Me --password myPasswd --quiet https://lnsvr0005/data/swreuse > "C:\\Temp\\ft.dump"

    Yet I can copy that exact output to a DOS shell and it runs. I am truly stumped.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: Problem using Swing to create a Subversion dump file

    We need to see a bit more of the (relevant) code; b.t.w. you can use forward slashes for path separators, i.e. C:/Program Files/Tortoies/ ... (there's no need to double them)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Brad is offline Member
    Join Date
    Feb 2012
    Posts
    21
    Rep Power
    0

    Default Re: Problem using Swing to create a Subversion dump file

    Here is the entire class. Let me know if you spot anything that is "off"

    Java Code:
    package SVN_Backup;
    
    import javax.swing.JOptionPane;
    
    public class Dumprepo {
        public void svndump(String svnrdump_exe, String username, String password, 
                            String source, String destination, String file, String version, String myButton){
            String error = null;
            String result = null;
            String item = null;
            Process p = null;
            
            //svnrdump_exe = svnrdump_exe.replace("\\", "\\\\");
            //svnrdump_exe = svnrdump_exe.replace("\\", "/");
            svnrdump_exe = "\"" +svnrdump_exe+ "\"";
    
            //destination = destination.replace("\\", "\\\\");
            //destination = destination.replace("\\", "/");
            destination = "\"" +destination+ "\\" + file+ ".dump\"";
            
            System.out.println(svnrdump_exe);
            System.out.println(destination);
    
            
    //        String full = svnrdump_exe + " dump --no-auth-cache --non-interactive " +
    //                      "--trust-server-cert --username " +username+ " --password " +
    //                      password + " --quiet " +source+ " > " +destination;
             String full = "cmd /c " + svnrdump_exe + " dump --username " +username+ " --password " +password + " --quiet " +source+ " > " +destination;                
         
            
            String incremental = svnrdump_exe + " dump --incremental --no-auth-cache --non-interactive " +
                          "--trust-server-cert --username " +username+ " --password " +
                          password + " --quiet " +source+ " > " +destination;
            
            String full_ver = svnrdump_exe + " dump --no-auth-cache --non-interactive " +
                          "--trust-server-cert --username " +username+ " --password " +
                          password + " --quiet -revision " +version+ " " +source+ " > " +
                          destination;
            
            String incremental_ver= svnrdump_exe + " dump --incremental --no-auth-cache --non-interactive " +
                          "--trust-server-cert --username " +username+ " --password " +
                          password + " --quiet -revision " +version+ " " +source+ " > " +
                          destination;    
            
            if("Full".equals(myButton)){
                  item = full;              
            }
            if("Full - Version".equals(myButton)){
                 item = full_ver;    
            }
            if("Incremental".equals(myButton)){
                item = incremental;
            }
            if("Incremental - Version".equals(myButton)){
                item = incremental_ver;
            }
            
            System.out.println(item);
            
            try {
                p = Runtime.getRuntime().exec(item);
                StreamGobbler outputGobbler = new
                   StreamGobbler(p.getInputStream(), "OUTPUT");
                
                StreamGobbler errorGobbler = new
                   StreamGobbler(p.getErrorStream(), "ERROR");
                    
                // kick them off
                outputGobbler.start();
                errorGobbler.start();
                
                error = errorGobbler.Error;
                result = outputGobbler.result;
                
                System.out.println(error);
                System.out.println(result);
                
                int returnVal = p.waitFor();
                if(returnVal != 0){
                   throw ( new Throwable()); 
               }
                
                } catch (Exception e){
                    JOptionPane.showMessageDialog(null,
                       "Could not create dump file: " + e.getMessage(), "Error", JOptionPane.WARNING_MESSAGE);
               } catch (Throwable T) {
                    JOptionPane.showMessageDialog(null,
                       "Could not create dump file: " + T.getMessage(), "Error", JOptionPane.WARNING_MESSAGE);
             }
        
        } 
    }
    By the way, I am just testing String full right now. I will get the other 3 working later.

Similar Threads

  1. Can you create a window/frame without using Swing?
    By Aggnavarius in forum New To Java
    Replies: 1
    Last Post: 09-02-2012, 02:02 PM
  2. Replies: 5
    Last Post: 04-26-2012, 02:52 PM
  3. create a carousel in java swing
    By tyrantblizz in forum AWT / Swing
    Replies: 2
    Last Post: 03-28-2012, 03:32 AM
  4. How to create Heat map for swing applications?
    By student91 in forum Advanced Java
    Replies: 1
    Last Post: 11-08-2011, 07:56 PM
  5. How to create Heat map for swing applications?
    By student91 in forum New To Java
    Replies: 1
    Last Post: 11-08-2011, 07:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •