Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I have

$copy = 'rsync -acz ubuntu@ec3-51-123-131-111.compute-1.amazonaws.com:/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!

share|improve this question
    
Have you tried running it from the shell command line? What was the result? –  Kyle Jones Apr 20 '13 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 '13 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 '13 at 8:36
    
is rsync in th path? which rsync may be /bin/rsync should work better in script? –  Yurij73 Apr 20 '13 at 13:00

1 Answer 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
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.