Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an rsync command that works fine from either the Bash command line or a Bash script.

The command is: rsync -qtz user@hostname:/tmp/p /tmp

When I run the command, it copies the file and runs in less than a second.

If I put the command in a Perl script, the script hangs, and I have to Control-C to kill it.

The Perl script is just this:

system("rsync -qtz user@hostname:/tmp/p /tmp");

What could be going wrong? Other commands (like mv and gzip) work fine in the Perl script. I tried specifying the4 complete path to /usr/bin/rsync, but it doesn't help.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The @ symbol is special inside double quoted strings in Perl.

It is trying to find an array named @hostname and expand it. @hostname is not set, so it is expanding to rsync -qtz user:/tmp/p /tmp.

Try

system("rsync -qtz user\@hostname:/tmp/p /tmp");

instead.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.