2

I am trying to do a rsync from amazon cloud to my local machine by using php.

I have

$copy = 'rsync -acz [email protected]:/project/file.txt .'

shell_exec ($copy)

However, the file is not copied and there is no error message as well. Can anyone give me a hint about it? Thanks so much!

4
  • Have you tried running it from the shell command line? What was the result?
    – Kyle Jones
    Apr 20, 2013 at 1:09
  • I believe there may be an error message on STDERR, this would possibly end up in your web servers' error log, and not in the page output as STDOUT might.
    – dlamblin
    Apr 20, 2013 at 1:48
  • what ssh key are you using? Is it asking for a password or have you set it up with a keychain / passwordless login? Remember I had a similar issue a while ago that was solved with using keychain.
    – James
    Apr 20, 2013 at 8:36
  • is rsync in th path? which rsync may be /bin/rsync should work better in script?
    – Yurij73
    Apr 20, 2013 at 13:00

1 Answer 1

1

There are a few things that could be going wrong here. First of all, you are missing a semi colon at the end of the $copy variable declaration. Your script should be

$copy = 'rsync -acz user@server:/home/user/foo.txt .';
shell_exec ($copy);

If that is just a typo in your post and not the way the real script is, make sure you can run the command correctly from a terminal, without needing to enter a password. If you can, launch your php script again but monitor your error logs. Assuming you are running this script through a an apache webserver, that would be

tail -f /var/log/apache2/error.log

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .