rsync command fails when called through system()
This is the command I'm using:
rsync --partial --timeout=60 --rsh='/usr/bin/ssh -i /root/.ssh/id_rsa' /path/file user@host:/remote_path/
This works when I run it on 开发者_JAVA技巧the command line, but does not work when I use system() in my C program.
Correction: This call will not work after boot up, no matter how long the program runs. If the program is restarted it will work every time no matter how many times the program is run.
status = system("rsync --partial --timeout=60 --rsh='/usr/bin/ssh -i /root/.ssh/id_rsa' /path/file user@host:/remote_path/");
The return value from rsync is 12: Error in rsync protocol data stream.
Turns out that the problem was the environment variables. HOME was set to '/' on start up instead of '/user'. ssh was unable to locate the known_hosts file and therefor the auto-login failed, causing rsync to fail.
精彩评论