2 Replies Latest reply: Sep 15, 2010 4:16 AM by 843810 RSS

    rsync white spaces

    843810
      Hi all, i'm creating my own desktop application that works with rsync.

      I'm trying to list directories content, but i'm not able to do this with path that contains blank spaces. To list directories with spaces i've tried:
      Process p = Runtime.getRuntime().exec("rsync /path_to_dir/dir with spaces/");
      
      Process p = Runtime.getRuntime().exec("rsync /path_to_dir/dir\ with\ spaces/");
      
      Process p = Runtime.getRuntime().exec("rsync \"/path_to_dir/dir with spaces/\"");
      
      Process p = Runtime.getRuntime().exec("rsync /path_to_dir/\"dir with spaces\"/");
      
      Process p = Runtime.getRuntime().exec(new String[]{"rsync", "/path_to_dir/\"dir with spaces\"/"});
      but none of these works. I'm trying this on a remote host on linux. I have to use rsync, can't list files and directories with java class "File", 'cos i got also to list file from a server which requires login.

      Any suggestions?

      Thanks in advance

      Edited by: eg. on Sep 8, 2010 6:49 AM
        • 1. Re: rsync white spaces
          843810
          You have a fundamental problem other than the space issue too: if you are going to use a backslash "\" for a separator, then you have to double backslash everyone of them.

          As far as rsync goes, there should be an escape character that you can use to solve the problem with the space. Google is your friend there: http://forums.macrumors.com/archive/index.php/t-761794.html is a link from google that speaks to your problem.
          • 2. Re: rsync white spaces
            843810
            Thanks, but i've just solved doing:
            Process p = Runtime.getRuntime().exec(new String[]{"rsync", "/path_to_dir/dir with spaces"});
            without any escape character