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

Posted on 2007-07-28
Last Modified: 2008-02-01

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" ./

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.

Question by:haidermosawi
    LVL 48

    Accepted 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 ./
    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.

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now