jshock wrote:
I have written a simple script that uses rsync to backup directories
to a USB drive. The directories are selected from an array. The
problem I am having is that if the directory has a space in it, the
script breaks.
I have tried putting backslashed in front of the spaces, and encasing
the entire path in single and double quotes. What am I doing wrong?
Here is the script:
#This is the list of files to backup
@source = qw(
"/Users/joe/Documents/Palm/"
"/Users/joe/Library/Application\ Support/AddressBook"
"/Users/joe/Library/Application\ Support/iCal"
"/Users/joe/Library/Mail"
);
$target = "/Volumes/TOSHIBA2/";
foreach(@source){
system("rsync -a $_ $target");
}
Use a list instead of a string:
system( 'rsync', '-a', $_, $target ) == 0
or die "system rsync failed: $?";
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/