• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 355
  • Last Modified:

Getting rsync to work on Windows, run from a PHP script


I'm using the symfony framework, and am trying to use rsync to update my server files.

I have PHP 5.2.3 installed, and am using cwRsync (my computer is Windows XP via Parallels, on a Mac).

When I run symfony's command in DOS to execute rsync, I get the following command:

rsync --progress --dry-run -azC --delete --exclude-from=config/rsync/exclude.txt -e "ssh -p22" ./ user@host.com:/usr/home/user/myproject/

But nothing else happens. When I cancel the command (by pressing Ctrl-C), I get the error:

Error in my_thread_global_end(): 1 threads didn't exit
Terminate batch job (Y/N)?

The code that's causing the command line to freeze is:

passthru($cmd.' 2>&1', $return);
$content = ob_get_contents();

symfony is meant to use SSH to handle rsync, and I contacted my host, and they said they support both rsync and SSH.

I'm not sure where the error is happening, but I suspect that this is a PHP issue.

Apologies if my suspicion is incorrect, and I would appreciate any help in directing me to where the problem and solution might be.

1 Solution
If the command does not work on the dos-box it won't work in php.
Try from the dosbox:
rsync --progress --dry-run -azC --delete --exclude-from=config/rsync/exclude.txt -e ssh ./ user@host.com:/usr/home/user/myproject/
If you get prompted for a password you won't be able to use that command through php, as you can't pass the password to the ssh-process via php.
haidermosawiAuthor Commented:
Thanks a lot..

I managed to get rsync working the way you prescribed. But I'm sure there's a way of getting it to work through PHP, otherwise symfony wouldn't be using it.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now