Ruby telnet issue when target platform is SuSE9.2

Hi,
When I use Net/telnet module on target platform SuSE9.2, I got an error
message like “Tset: Unknown terminal type network”.

I also tried to replace “login” fuction with “Waitfor” fuction, but it
is still the case.

Furthermore, I try to modify the options “Prompt” to another regular
expression that matches the prompt of SuSE 9.2, but it still does not
work.

I used google to search for reasons about this issue.
And I found maybe the default terminal type of SuSE9.2 should be
modified to make my program work.

Have anyone met the same problem? And could anyone give me a hand about
how to configure SuSE9.2 terminal type?

Additional info: my SuSE used bash shell as default shell. And the
enviroment “TERM” is “xterm” and I examined the “/etc/termcap” and found
nothing valuable.

Thanks a lot!

Jia Zhang wrote:

Hi,
When I use Net/telnet module on target platform SuSE9.2, I got an error
message like “Tset: Unknown terminal type network”.

I also tried to replace “login” fuction with “Waitfor” fuction, but it
is still the case.

Furthermore, I try to modify the options “Prompt” to another regular
expression that matches the prompt of SuSE 9.2, but it still does not
work.

I used google to search for reasons about this issue.
And I found maybe the default terminal type of SuSE9.2 should be
modified to make my program work.

Have anyone met the same problem? And could anyone give me a hand about
how to configure SuSE9.2 terminal type?

Additional info: my SuSE used bash shell as default shell. And the
enviroment “TERM” is “xterm” and I examined the “/etc/termcap” and found
nothing valuable.

Thanks a lot!

Hi,
I solved this problem since I met the same issue as you. Below is my
code, you can refer to it. Any question, just mail to me:
[email protected]


require ‘net/telnet’

telnet = Net::Telnet.new(‘Host’ => ‘Your IP’,
‘Prompt’ => /[ftpusr@suse46:~>]*\z/n)
#The prompt should be the real prompt while you entered your system

telnet.waitfor(/[Ll]ogin[: ]\z/n) {|c| print c}
telnet.cmd(“Your User”) {|c| print c}
telnet.waitfor(/Password[: ]
\z/n) {|c| print c}
telnet.cmd(“Your password”) {|c| print c}
telnet.cmd(“dumb”) {|c| print c}
#This is must, because in SuSE, by default, the terminal type is “dumb”
#Then, send your command here
telnet.cmd(‘df -k’){|c| print c}
STDOUT.flush
#Here, wait for the prompt
telnet.waitfor(/[$%#>] \z/n) {|c| print c}
#Then, leave the system
telnet.cmd(‘exit’) {|c| print c}
telnet.close

Enjoy Ruby!