novawolf1 has asked for the wisdom of the Perl Monks concerning the following question:

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!!!!!!!!!