Max Kipness
2003-Dec-17 12:30 UTC
Rsyncing Windows directory to a Linux box: problem with spacesin directory names
> > >> > I am trying to rsync folders/files hosted on a Windows > machine to a > >> > Linux machine. Many of the directory names have spaces in them. > >> > How can I list them in a file so that the --include-from > option use > >> > them correctly? > >> > Thanks! > >> > > >> > Charles > >> > >> try\ escaping\ the\ spaces\ like\ this "or perhaps quoting" > > > > I just include them with the spaces and it works fine. This is with > > Redhat 8 or 9. > > Max, > > Here are more details on the problem. > > The complete script I am using can be found there: > http://www.mikerubel.org/computers/rsync_snapshots/contributed > /rob_bos. The command from this script that cause me problem > is: rsync -va --delete > --modify-window=2 --delete-excluded > --exclude-from=$excludefile $backup $backuproot/$type.1/ > > Where: > $backup=`cat /etc/snapshot/include.text` $backuproot=/backup > $excludefile=/etc/snapshot/exclude.text > $type=hourly > > /etc/snapshot/include.text contains: > /diskbox/Mariage/*.tdk > /diskbox/Mariage/*.ppj > /diskbox/Outlook/ > /diskbox/PourCD/ > /diskbox/Toburn/ > /diskbox/Anciens projets/ > > /etc/snapshot/exclude.text contains: > diskbox/Mariage/*.AVI > diskbox/Mariage/*.wmv > diskbox/Mariage/*.rm > diskbox/Mariage/*.mp2 > diskbox/Outlook/Outlook/*.* > > When I execute the script above with a directory name > containing space in include.text, I get the following error message: > > building file list ... link_stat /diskbox/Anciens : No such > file or directory link_stat projets/. : No such file or > directory done IO error encountered - skipping file deletion ./ > > Anything I could do besides trying to escape the space or > putting the whole directory between double quote?Not sure what the problem is. Could it be an OS issue? I noticed a difference in general with the way Redhat 8.0 handled directories/folders with spaces in them vs. Redhat 7.3. I've got many include files with spaces in them, especially with the 'Documents and Settings' directories for all the XP/2000 workstations that I back up. And I'm not using any quotes. The only other thing I can think of is to have your script enclose the entire line in double quotes as in: "/diskbox/Anciens projets/" Max
Max Kipness
2003-Dec-17 13:08 UTC
Rsyncing Windows directory to a Linux box: problem with spacesin directory names
> On Wed, Dec 17, 2003 at 09:05:50AM +0900, Charles Nadeau wrote: > > backup=`cat /etc/snapshot/include.text` rsync -va [...] $backup > > $backuproot/$type.1/ > > This is entirely a shell issue -- the shell you are using is > splitting the args at all whitespace, and you need to tell it > to stop. In fact, in some shells $backup would always refer > to a single arg unless you run the line through an extra > "eval ..." sequence (bourne shell and bash does way too much > word splitting for my tastes, for instance). > > One option is to use a more advanced shell expansion of the > file into args. In zsh (my shell of choice), you can do > something like this: > > rsync -va --OPTIONS "${(f)$(</path/include.text)}" > $backuproot/$type.1/ > > This takes the contents of the include.text file, splits in > by lines, and quotes each one as a separate arg. If you're > not using zsh, perhaps someone familar with the shell you are > using can assist you with something similar. > > Another option is to upgrade to the CVS version (available in > the near future as version 2.6.0) and use the --files-from > option to specify your files (since it already parses the > names one per line).Charles, Based on what was just said above, I am using Bash version 2.05b.0(1), and no extra configs for splitting are necessary as it splits appropriately at the end of the line. Max
Max Kipness
2003-Dec-17 14:00 UTC
Rsyncing Windows directory to a Linux box: problem with spacesin directory names
> > Based on what was just said above, I am using Bash version > 2.05b.0(1), > > and no extra configs for splitting are necessary as it splits > > appropriately at the end of the line. > > No, bash splits on all whitespace by default. Take a file like this: > > one two three > four five six > seven eight nine > > put it in a var: > > foo=`cat file` > > and then expand it: > > echo $foo > > This echo command gets 9 separate args. If you use this: > > echo "$foo" > > This echo command gets just 1 arg (with spaces and newlines included). > > However, if you set IFS to contain just a newline, then the > unquoted $foo reference returns 3 args. So, that's one > possible bash solution.You are right about the splitting above, however I can use spaces in my include file without issue. I don't know whether it is due to Bash or not, but I do this on several Redhat 8/9 servers without modification to the shell. Here is my include file: + BACKOFFICE/ + BACKOFFICE/C$/ + BACKOFFICE/C$/Documents and Settings/ - BACKOFFICE/C$/* - BACKOFFICE/* + RAE-DELL/ + RAE-DELL/C$/ + RAE-DELL/C$/Documents and Settings/ - RAE-DELL/C$/* - RAE-DELL/* + SERVER/ + SERVER/C$/ + SERVER/C$/Documents and Settings/ - SERVER/C$/* + SERVER/E$/ + SERVER/E$/Files/ + SERVER/E$/Files/Office/ + SERVER/E$/Files/Users/ - SERVER/E$/Files/* - SERVER/E$/* - /* And here is a partial listing of the log: building file list ... readlink AMY/C$/hiberfil.sys: Text file busy readlink AMY/C$/pagefile.sys: Text file busy readlink 3RDFLOOR/C$/hiberfil.sys: Text file busy readlink 3RDFLOOR/C$/pagefile.sys: Text file busy readlink RAE-DELL/C$/hiberfil.sys: Text file busy readlink RAE-DELL/C$/pagefile.sys: Text file busy done 3RDFLOOR/C$/Documents and Settings/All Users/ 3RDFLOOR/C$/Documents and Settings/All Users/Application Data/Creative/Media Database/ALBUM. DBF 3RDFLOOR/C$/Documents and Settings/All Users/Application Data/Creative/Media Database/ALBUM0 .CDX 3RDFLOOR/C$/Documents and Settings/All Users/Application Data/Creative/Media Database/ARTIST .DBF Max
Charles Nadeau
2003-Dec-17 15:24 UTC
Rsyncing Windows directory to a Linux box: problem with spacesin directory names
Max Kipness wrote:>> Anything I could do besides trying to escape the space or >> putting the whole directory between double quote? > > Not sure what the problem is. Could it be an OS issue? I noticed aMax, I am using Gentoo 1.4. Thanks! Charles> difference in general with the way Redhat 8.0 handled > directories/folders with spaces in them vs. Redhat 7.3. > > I've got many include files with spaces in them, especially with the > 'Documents and Settings' directories for all the XP/2000 workstations > that I back up. And I'm not using any quotes. > > The only other thing I can think of is to have your script enclose the > entire line in double quotes as in: > > "/diskbox/Anciens projets/" > > Max-- Charles-E. Nadeau Ph.D http://radio.weblogs.com/0111823/
Charles Nadeau
2003-Dec-17 15:27 UTC
Rsyncing Windows directory to a Linux box: problem with spacesin directory names
Max Kipness wrote:>> Another option is to upgrade to the CVS version (available in >> the near future as version 2.6.0) and use the --files-from >> option to specify your files (since it already parses the >> names one per line). > > Charles, > > Based on what was just said above, I am using Bash version 2.05b.0(1),Max, Me too: Mosix7 / # bash --version GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu) Copyright (C) 2002 Free Software Foundation, Inc.> and no extra configs for splitting are necessary as it splits > appropriately at the end of the line.Could it then be my version of rync? Mosix7 / # rsync -v rsync version 2.5.7 protocol version 26 Copyright (C) 1996-2002 by Andrew Tridgell and others <http://rsync.samba.org/> Capabilities: 64-bit files, socketpairs, hard links, symlinks, batchfiles, IPv6, 64-bit system inums, 64-bit internal inums Thanks! Charles> > Max-- Charles-E. Nadeau Ph.D http://radio.weblogs.com/0111823/
jw schultz
2003-Dec-17 16:13 UTC
Rsyncing Windows directory to a Linux box: problem with spacesin directory names
On Wed, Dec 17, 2003 at 01:27:42PM +0900, Charles Nadeau wrote:> Max Kipness wrote: > > >> Another option is to upgrade to the CVS version (available in > >> the near future as version 2.6.0) and use the --files-from > >> option to specify your files (since it already parses the > >> names one per line). > > > > Charles, > > > > Based on what was just said above, I am using Bash version 2.05b.0(1), > > Max, > > Me too: > > Mosix7 / # bash --version > GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu) > Copyright (C) 2002 Free Software Foundation, Inc. > > > > and no extra configs for splitting are necessary as it splits > > appropriately at the end of the line. > > Could it then be my version of rync?No. As has been repeatedly said the problem is with how you are dealing with whitespace in the shell. If you insist on fighting this battle with fagile methods you need to start debugging the problem. In your script replace rsync with this shell script ----------------------- #/bin/bash for arg in "$@" do echo $arg done ----------------------- Then you can fiddle with escapements and IFS and other tricks. Do that until you get one expected argument per line of output then put rsync back into the picture. This is not an rsync problem, it is a shell problem. There are many resources out there for shell scripting. The rsync mailing list is not one of them. Good luck -- ________________________________________________________________ J.W. Schultz Pegasystems Technologies email address: jw@pegasys.ws Remember Cernan and Schmitt
Reasonably Related Threads
- Rsyncing Windows directory to a Linux box: problem with spaces in directory names
- 32 seconds vs 72 minutes -- expected performance difference?
- [Rails 3.2] form_tag w :remote => true doesn't fire up the js format
- How index works!
- [Rails 3.2.8] issue in regex scan