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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -