[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

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

Hello,

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:

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

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.



0
haidermosawi
Asked:
haidermosawi
1 Solution
 
hernst42Commented:
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.
0
 
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.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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