Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing script were rsync should be called and ask for password. However I cannot pass IP as argument. I think I am missing something simple. Any ideas? Even trivial script like this just outputs nothing, just stucks:

rsync -avzh -P $1 $3@$2:/opt/stuff/

When I put IP it worked:

rsync -avzh -P $1 $3@

Tried escaping colon, didn't helped, echo'ed everything and it just showed similar line. I think it is something related to interactivity.

share|improve this question
Are you sure about the value of $2 at that point? Print it out with printf '[%s]\n' "$2" | cat -v to check that it contains the IP address only. – Gilles Feb 10 '14 at 8:40
In my case I got [] no hidden symbols, nothing – IBr Feb 10 '14 at 8:58
Run your script with the -x flag: sh -x myscript dirname address username. This will show you how sh interprets your script. – Warren Young Feb 10 '14 at 9:12
+ rsync -avzh -P ../file.txt user@ - perfect, but still same results. – IBr Feb 10 '14 at 9:16
Wait after some time I got: "ssh: connect to host port 22: Connection timed out rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0] " – IBr Feb 10 '14 at 9:17

Your Answer


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

Browse other questions tagged or ask your own question.