From: Hugh Sasse Date: 2006-11-09T03:32:35+09:00 Subject: Re: Net::SSH Data Stream Problem On Thu, 9 Nov 2006, Andrew Stewart wrote: > > On 8 Nov 2006, at 17:56, Hugh Sasse wrote: > > > OK, given they're both unices, that figures... I'd then read and > > write in smaller chunks. I don't do enough deep networking to know > > what packet sizes are sensible, but... [ri output] > > ...probably a good idea to check the return value. And for f.read. > > I changed this: [...] > To this: > > open(source_path) { |f| > x = f.read > puts "x: #{x.length}" > result = stdin.write x > puts "result: #{result}" > } > > And it told me that x is the size of my file, so f.read is reading in the > entire file. what was #{result}? Oh ... > > The stdin object is an instance of SSHStdinPipe. The documentation for its > write method [1] says: "Write the given data as channel data to the underlying > channel." I.e. it doesn't mention anything about size limits. ... and write doesn't return how many things it wrote breaking the Duck Type that says "treat me like IO". Rats. > > But clearly there is a size limit somewhere and the 'stdin.write data' method > must be the line which hits it. I dug into the source but got a bit confused. > > Any more ideas? I'd read then write q bytes at a time until the whole file is read I think the value for q is the length of the file you ended up with at the far end. That would make a good start for a search, anyway. > > Thanks, > Andy > > [1] > http://net-ssh.rubyforge.org/api/classes/Net/SSH/Service/Process/POpen3Manager/SSHStdinPipe.html Nice docs, except for not being able to see and navigate to the parent class easily. Hugh >