Hello All, I am trying to use the Net::Telnet module to connect to UNIX machines and gather information about kernel parameters, file systems, applications, patch levels and so on. Here is the issue: I get varying output each time I run my script. It seems like the Net::Telnet module is having problems reading from its own buffer. I have been working on the problem for about a week thinking it was my code, but I can now make it happen even with a simple script. The systems I am connecting to are not under my direct care (i.e. the prompts, shell settings, everything can be different). I am also trying to do this without FTP'ing code to the server and running it for there. I would like to get a module running that would connect and allow for individual processes to be called by my main program. CLIENT SYSTEM: Windows 2000 Service Pack 4 PIII - 1000MHz SERVER SYSTEMS: HPUX 11i - (But I will actually be connecting to HP, AIX and LINUX). SCRIPT:
#!/usr/local/bin/perl #=================================== ######################################### # START REQUIREMENTS ######################################### require 5.6.1; ######################################### # END REQUIREMENTS ######################################### ######################################### # START USE ######################################### use 5.6.1; use Net::Telnet; use strict; ######################################### # END USE ######################################### ######################################### # START MAIN ######################################### my ( $host, $hostname, @line1, @line2, $username, $passwd, $pro ); $hostname = "hp1"; $username = "root"; $passwd = "******"; ## Connect and login. use Net::Telnet (); $host = new Net::Telnet ( Timeout => 30, Prompt => '/[\$%#>] $/', Output_log => 'TELNET.out', Input_log => 'TELNET.out'); $host->open($hostname); $host->login($username, $passwd); $pro = "/##\$/"; #Set prompt code my $rc1 = $host->prompt("$pro"); #Debugging print "RC 1 -> $rc1\n"; #Set prompt on unix side my $rc2 = $host->cmd('PS1="##" export PS1'); #Debugging print "RC 2 -> $rc2\n"; #Get os type (@line1) = $host->cmd("uname"); #Debugging print " LINE 1 -> $line1[0]\n"; #Get hostname (@line2) = $host->cmd("hostname"); #Debugging print "LINE 2 -> @line2\n"; ######################################### # END MAIN ######################################### ######################################### # START SUBROUTINES ######################################### ######################################### # END SUBROUTINES ######################################### __END__ #End of running code
OUTPUT: This output was run against the same server, within 15 seconds of each other.
1 ############################### RC 1 -> /[\$%#>] $/ RC 2 -> 1 LINE 1 -> HP-UX LINE 2 -> hostname hp1 2 ############################### RC 1 -> /[\$%#>] $/ RC 2 -> 1 LINE 1 -> ##uname LINE 2 -> hp1 3 ############################### RC 1 -> /[\$%#>] $/ RC 2 -> 1 LINE 1 -> HP-UX LINE 2 -> hp1
PLEASE HELP!!! Thank you in advance for all your time and effort ohh great monks!!!!!!!!!

In reply to Net::Telnet -> Strange variable output by novawolf1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.