Forum: Ruby Ruby telnet issue when target platform is SuSE9.2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
901f3352eafdfa3e41243f06e9df56e5?d=identicon&s=25 Jia Z. (saga)
on 2006-06-13 06:48
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!
1fd2bae6abbcd4723f01167a05b82663?d=identicon&s=25 Sea Z. (seazhang)
on 2006-12-14 04:03
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:
sszhang_2003@hotmail.com

---------------------------------------------------------------------------
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!
This topic is locked and can not be replied to.