Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Trying to use Net::Telnet from Linux to a XP machine [connection refused]

by TASdvlper (Monk)
on Oct 27, 2003 at 18:19 UTC ( #302458=perlquestion: print w/ replies, xml ) Need Help??
TASdvlper has asked for the wisdom of the Perl Monks concerning the following question:

All,

I'm trying to use the Net::Telnet module to run a script on a XP machine being executed from a Linux machine and I'm getting the following error.

problem connecting to "IP of XP machine", port 23: Connection refused at Telnet.pl line 11

This is my 1st time using the Telnet module so maybe I'm overlooking something (??). I even tried to manually run a telnet to the XP system with no success and the same error message. I'm not sure what to try from here ....

use strict; use warnings; use Net::Telnet; my $t; my $host = "IP of XP machine"; my $perl_path = "/msg/spgear/tools/bin/perl"; my @lines; $t = new Net::Telnet( Timeout => '10') || die "Could not create Telnet + object: $@ -- $!\n"; $t->open($host) || die "Could not open connection to host: $host $@ -- + $!\n";
... rest of program ...

Comment on Trying to use Net::Telnet from Linux to a XP machine [connection refused]
Download Code
Are you sure that XP is responding?
by DentArthurDent (Monk) on Oct 27, 2003 at 18:26 UTC
    Are you sure that you have a telnet server running on your XP box? Nearly all Windows versions do not have server functionality that you expect by default from *nix operating systems. You would have to get a telnet server for windows off the net. I'm sure you could find a free one very easily.
    ----
    May your tongue cleave to the roof of your mouth with the force of a thousand caramels.
      Actually, I am not sure. I will check shortly (I think I made a bad assumption it was running). I'm a bit new to running Perl in a Windows env. Would you have any recommendations besides using a telnet server ?

      To explain my situation, from a master server I want to be able to run scripts on a remote windows system. Initially I thought rsh was the way to go, so then I thought about writing a client/server app, but if I can help it, I don't want a remote system to have the dependancy of running a script and "listening" for commands to execute.

      I've also been told ssh and SOAP::Lite might be worth considering.

Re: Trying to use Net::Telnet from Linux to a XP machine [connection refused]
by BazB (Priest) on Oct 27, 2003 at 18:26 UTC

    Is there a telnet server running on the XP machine?


    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

      And if so, please explain :)

      ----
      I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
      -- Schemer

      :(){ :|:&};:

      Note: All code is untested, unless otherwise stated

Re: Trying to use Net::Telnet from Linux to a XP machine [connection refused]
by Limbic~Region (Chancellor) on Oct 27, 2003 at 18:28 UTC
    TASdvlper,
    First of all, there is a known problem with using Net::Telnet to a windows box. With that said, you probably do not have the service running.
    c:\> netstat -an | find ":23"
    If you do not see the machine listening on port 23, you will need to enable it as a service. Be sure to read the notes at the bottom, since there are some differences between WinXP and 2003.

    If it is running, something is blocking the connection such as IPSec.

    Cheers - L~R

      I got the telnet service running and I can telnet from a command line, but in the script I'm getting the following message:

      timed-out waiting for command prompt at Telnet.pl line 13 (line 13 is the $t->login(...) command.

        As offered up in Limbic~Region's link.

        When a TELNET server first accepts a connection, it must use the ASCII control characters carriage-return and line-feed to start a new line (see RFC854). A server like the "Microsoft Telnet Server" that doesn't do this, isn't a TELNET server. These servers send ANSI terminal escape sequences to position to a column on a subsequent line and to even position while writing characters that are adjacent to each other. Worse, when sending output these servers resend previously sent command output in a misguided attempt to display an entire terminal screen.

        Connecting Net::Telnet to one of these false TELNET servers makes your job of parsing command output very difficult. It's better to replace a false TELNET server with a real TELNET server. The better TELNET servers for MS-Windows allow you to avoid the ANSI escapes by turning off something some of them call console mode.

        You mention you are running the MS Telnet Service....I think that everyone here is right...that is the culprit and you might consider replacing it with an RFC compliant Telnet Server

Re: Trying to use Net::Telnet from Linux to a XP machine [connection refused]
by mandog (Curate) on Oct 27, 2003 at 19:59 UTC

    Other monks have pointed to problems with MS telnet server's implementation. My guess is that you've not reached these problems yet as the Telnet server that comes with win2k & up uses funky Microsoft only authentification by default

    For win2K (and probably XP) you need to look in the local microsoft help for "telnet admin" and follow the bouncing wizard to change authentication from "NTLM" to "plain."

    If MS telnet server doesn't work w/ Net::Telnet and you hae to install another server anyway, consider a ssh server as you won't be passing passwords over the net in the clear. Every cracked box I've seen or heard of has had a password sniffer installed

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://302458]
Approved by snax
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-08-21 07:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (128 votes), past polls