terminal - Perl - using rsync from perl script -
terminal - Perl - using rsync from perl script -
i'm having problem writing simple perl script can sync 2 folders. code is:
my $string= "rsync -va ~/dropbox/music\ \(1\)/ ~/music/music/"; `$string`;
i tried using line
`rsync -va /dropbox/music\ \(1\)/ ~/music/music/;`
next tried:
my @args=("bash", "-c","rsync -va ~/dropbox/music\ \(1\)/ ~/music/music/"); system(@args);`
i same error:
sh: -c: line 0: syntax error near unexpected token `(' each time
(yeah, spaces , parens in originating folder pain, don't yell @ me, didn't create it....)
the problem actual shell command you're running is
rsync -va ~/dropbox/music (1)/ ~/music/music/
because backslashes swallowed perl (since it, bash, uses backslash quoting/escape character). avoid this, need either utilize single-quotes:
system 'rsync -va ~/dropbox/music\ \(1\)/ ~/music/music/';
or else re-escape backslashes:
system "rsync -va ~/dropbox/music\\ \\(1\\)/ ~/music/music/";
perl terminal command
Comments
Post a Comment