Professional Web Applications Themes

Net::Telnet problem with MS Telnet Service - PERL Modules

Hello, After reading the Net::Telnet doentation, examples, searching the 'Net, etc., I still do not completely understand the problem of connecting to a "Microsoft Telnet Server". I'm sure someone has already touched on this before.. If so, sorry about the repeat. Using a different Telnet server is not really an option at this point in time. The problems outlined in the module man pages under "Connecting to a Remote MS-Windows Machine" seem to be clear, however, is it not at all possible to capture the output? I must be missing something... or could someone explain to me why it appears ...

  1. #1

    Default Net::Telnet problem with MS Telnet Service

    Hello,

    After reading the Net::Telnet doentation, examples, searching the
    'Net, etc., I still do not completely understand the problem of
    connecting to a "Microsoft Telnet Server".

    I'm sure someone has already touched on this before.. If so, sorry about
    the repeat. Using a different Telnet server is not really an option at
    this point in time.

    The problems outlined in the module man pages under "Connecting to a
    Remote MS-Windows Machine" seem to be clear, however, is it not at all
    possible to capture the output? I must be missing something... or could
    someone explain to me why it appears in the log but it cannot be captured?

    Note: names/details have been change to protect the innocent. :o)

    For example,

    #!/usr/bin/perl
    use strict;
    use Net::Telnet;

    my $username = "tester";
    my $password = "pass_test";

    my $t = new Net::Telnet(
    Timeout => 5,
    Host => hostname,
    Errmode => "return"
    );

    $t->login( $username, $password );

    my $prompt = "_MYPROMPT_";
    $t->prompt("/$prompt\$/");
    $t->cmd("prompt = '$prompt'");
    my $string = "java -version";
    my jver = $t->cmd($string);
    $t->close;


    The jver array contains no output after running the script. If I use
    input_log(), the following appears in the log:

    ###########
    Welcome to Microsoft Telnet Service

    login: tester
    password:

    *================================================= ==============
    Welcome to Microsoft Telnet Server.
    *================================================= ==============
    C:\Doents and Settings\tester>prompt = '_MYPROMPT_'

    '_MYPROMPT_'java -version
    java version "1.4.2_03"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03)
    Java HotSpot(TM) Client VM (build 1.4.2_03, mixed mode)

    '_MYPROMPT_'
    ###########


    Using dump_log(), the following appears (snipped):


    ###########
    < 0x00000: 57 65 6c 63 6f 6d 65 20 74 6f 20 4d 69 63 72 6f Welcome
    to Micro
    < 0x00010: 73 6f 66 74 20 54 65 6c 6e 65 74 20 53 65 72 76 soft
    Telnet Serv
    < 0x00020: 69 63 65 20 0d 0a 0a 0d 6c 6f 67 69 6e 3a 20 ice
    .....login:

    <snip>
    > 0x00000: 70 72 6f 6d 70 74 20 3d 20 27 5f 4d 59 50 52 4f prompt =
    > '_MYPRO
    > 0x00010: 4d 50 54 5f 27 0d 0a MPT_'..
    < 0x00000: 70 72 6f 6d 70 74 20 3d 20 27 5f 4d 59 50 52 4f prompt =
    '_MYPRO
    < 0x00010: 4d 50 54 5f 27 0d 0a 0d 0a 27 5f 4d 59 50 52 4f
    MPT_'....'_MYPRO
    < 0x00020: 4d 50 54 5f 27 MPT_'
    > 0x00000: 6a 61 76 61 20 2d 76 65 72 73 69 6f 6e 0d 0a java -
    > version..
    < 0x00000: 6a 61 76 61 20 2d 76 65 72 73 69 6f 6e 0d 0a 6a java -
    version..j
    < 0x00010: 61 76 61 20 76 65 72 73 69 6f 6e 20 22 31 2e 34 ava
    version "1.4
    < 0x00020: 2e 32 5f 30 34 2d 65 72 22 0d 0a 4a 61 76 61 28 .2_03"..Java(
    < 0x00030: 54 4d 29 20 32 20 52 75 6e 74 69 6d 65 20 45 6e TM) 2
    Runtime En
    < 0x00040: 76 69 72 6f 6e 6d 65 6e 74 2c 20 53 74 61 6e 64
    vironment. Stand
    < 0x00050: 61 72 64 20 45 64 69 74 69 6f 6e 20 28 62 75 69 ard
    Edition (bui
    < 0x00060: 6c 64 20 31 2e 34 2e 32 5f 30 34 2d 65 72 2d 32 ld 1.4.2_03
    < 0x00070: 30 30 34 30 33 31 30 29 0d 0a 4a 61 76 61 20 48 )..Java H
    < 0x00080: 6f 74 53 70 6f 74 28 54 4d 29 20 43 6c 69 65 6e
    otSpot(TM) Clien
    < 0x00090: 74 20 56 4d 20 28 62 75 69 6c 64 20 31 2e 34 2e t VM
    (build 1.4.
    < 0x000a0: 32 5f 30 34 2d 65 72 2d 32 30 30 34 30 33 31 30 2_03
    < 0x000b0: 2c 20 6d 69 78 65 64 20 6d 6f 64 65 29 0d 0a 0d . mixed
    mode)...
    < 0x000c0: 0a 27 5f 4d 59 50 52 4f 4d 50 54 5f 27 .'_MYPROMPT_'
    ############


    I used waitfor() and print() but it did not work either. Is the syntax
    below correct? According to the examples, it appears so and with a perl
    expression of /java/ I would think that it should at least match something.


    #########
    my $matchop = '/java/';
    (my $prematch, my $match) = $t->waitfor($matchop);
    $t->print("java -version");
    ##########

    Anyone have any ideas how I can capture this output? Or is it a hopeless
    case over a MS Telnet Service?

    Thanks for any help!
    texbmex

    texbmex Guest

  2. #2

    Default Re: Net::Telnet problem with MS Telnet Service

    texbmex wrote:
    > my $prompt = "_MYPROMPT_";
    > $t->prompt("/$prompt\$/");
    That says you expect the prompt to be "_MYPROMPT_".
    > $t->cmd("prompt = '$prompt'");
    But that causes the prompt to be "'_MYPROMPT_'".
    Have you tried that without the single quotes?
    -Joe
    Joe Smith Guest

  3. #3

    Default Re: Net::Telnet problem with MS Telnet Service

    Thanks! That did the trick... I knew I had to have been missing
    something. At least it was simple! :o)

    texbmex

    Joe Smith wrote:
    > texbmex wrote:
    >
    >> my $prompt = "_MYPROMPT_";
    >> $t->prompt("/$prompt\$/");
    >
    >
    > That says you expect the prompt to be "_MYPROMPT_".
    >
    >> $t->cmd("prompt = '$prompt'");
    >
    >
    > But that causes the prompt to be "'_MYPROMPT_'".
    > Have you tried that without the single quotes?
    > -Joe
    texbmex Guest

Similar Threads

  1. How do you telnet from 1 host to another using Telnet Module
    By mark1.thompson45@btinternet.com in forum PERL Modules
    Replies: 5
    Last Post: December 30th, 10:13 PM
  2. Problem with Net::Telnet
    By Gary in forum PERL Modules
    Replies: 0
    Last Post: October 20th, 11:19 PM
  3. net::telnet to ms telnet server
    By jm in forum PERL Modules
    Replies: 0
    Last Post: May 18th, 11:28 PM
  4. Telnet Service
    By Dave Hatcher in forum Windows Server
    Replies: 0
    Last Post: June 11th, 02:08 AM
  5. net/telnet problem
    By Mark Probert in forum Ruby
    Replies: 2
    Last Post: September 10th, 07:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139