I'm writing a script that will utilize rsync to push from a master sever to several child nodes. I won't bore you with most of my script (though in my Ruby infancy I'm especially proud of it), but I'm running into an issue when Ruby runs the rsync binary. I've rsync standalone with the same parameters and it work, but does not work through the script. Here's the output I get:
rsync: link_stat "/Shared Items/Share/\#012" failed: No such file or directory (2) rsync: push_dir#3 "/Users/ckbrumb/Desktop/Projects/ruby_sync/@/Shared Items/Share" failed: No such file or directory (2) rsync error: errors selecting input/output files, dirs (code 3) at /SourceCache/rsync/rsync-42/rsync/main.c(580) [receiver=2.6.9] rsync: connection unexpectedly closed (8 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
And here's that portion of the script:
def perform_sync
File.foreach(@filename) do |line|
serv_path_array = line.split(":")
shr_server = serv_path_array[0]
shr_path = serv_path_array[1]
shr_user = serv_path_array[2]
`rsync -avrpogz --delete -e ssh "#{@master_share}" "#{shr_user}@#{shr_server}:#{shr_path}"`
end
end
@master_share
is an initialized variable set by reading the first line of preference file the script lays down during its first run. It returns the proper path in all testing. For the destination share (shr_user@shr_server:shr_path
), the rest of the lines of that file are formatted like so: <serverName>:<user>:<path>
. The script splits this line with the :
as the delimiter and the variables are set based on the associated position in the array.
For the first line of the error, I've tried both having no \
to escape the space and leaving it as is with the same result in both cases. The \#012
is throwing me off, but I've yet been unable to track that (escape code?) down.
For the "error in protocol datastream" issue, I did see Why is this rsync connection unexpectedly closed on Windows? that mentions rsync being in different locations on the servers. I'll look into that, however, I'm going from a 10.8.3 to a 10.8.3, and I've not messed with any binary locations, so it's almost impossible that that's the issue.
I've still have some research to do on this, but with the issue only existing when calling rsync from my script, I'm hoping someone sees what the problem is and can push me in the right direction.
UPDATE: Just made a little progress. The first part of the error is because of how the @master_share variable is passing the string. I took that out and put the path to the share directly in quotes and it got past that point. Now it hangs up when asking for a password. Will not accept the correct password. In the end I'm going to have a proper authorized_keys file set up, but for now I'm just entering the password when rsync asks for it while the script is running. Is it possible that the password I enter isn't being passed through the script to rsync?