I'm trying to use the telnet library. I don't know Ruby AT ALL
(evaluating it side by side with Python to see which is going to be best
for my admin chores; this is my very first script), and this has got me
stumped:
require 'net/telnet'
t = Net::Telnet::new(
'Host' => 'somehost.com',
'Prompt' => /:.*>/,
)
out = lambda do |c| print c end
t.login('someusername', 'somepassword', &out)
t.cmd('dir', &out)
t.cmd('dir', &out)
The second dir command hangs with the server responding "More?" Here's
the tail end of the output log, after the first dir command:
...
04/13/2011 04:21 PM <DIR> Searches
04/13/2011 04:21 PM <DIR> Videos
04/16/2011 12:54 AM 6,558 _viminfo
1 File(s) 6,558 bytes
13 Dir(s) 279,022,981,120 bytes free
C:\Users\foo>dir
More?
And it just hangs there.
Full logs here (names changed to protect the innocent):
http://tetzfiles.com/temp/output_log
http://tetzfiles.com/temp/dump_log
This is a bitch to Google ("?" is ignored), but I found someone else
asking the same question on Stackoverflow, but he got no response
(http://stackoverflow.com/questions/3450942/ruby-telnet-lib-weird-response).
You guys could help both of us out. 
···
------------------------------------------------------------------
In a slightly unrelated question, I don't understand why I have to do
this:
out = lambda do |c| print c end
t.login('someusername', 'somepassword', &out)
t.cmd('dir', &out)
t.cmd('dir', &out)
Rather than simply this:
t.login('someusername', 'somepassword', &print)
t.cmd('dir', &print)
t.cmd('dir', &print)
Seems kinda pointless to make a function which does nothing but pass
it's arguments unaltered to another function.
--
Posted via http://www.ruby-forum.com/.