View Single Post
  #2  
Old 11-28-2009, 12:04 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

I revised the script and put all of the telnet commands into sub functions.

Code:
#!/usr/bin/perl

#eqstatus.pl
#By:Cubber
#Script to print out information about the eqemu server
#Uses Net::Telnet module
#11-25-2009

use strict;
use warnings;
use Net::Telnet();

my $i;
my $telnet;

$telnet = new Net::Telnet (Timeout=>10, Port=>'9000', Prompt=>'/\> $/');
$telnet->open("192.168.1.21");
$telnet->login("username", "password");

&Version;
&Uptime;
&Who;
&Zones;
exit;

sub Version()

{

my @version;

@version = $telnet->cmd("version");
my $vercnt = $#version;

for($i=1;$i<$vercnt;$i++)
	{
		print $version[$i];
	}

print "\n";

}


sub Uptime()

{

my @uptime;

@uptime =  $telnet->cmd("uptime");
print $uptime[1];
print "\n";

}


sub Who()

{

my @who;

@who = $telnet->cmd("who");
my $whocnt = $#who;

for($i=1;$i<$whocnt;$i++)
	{
		print $who[$i];
	}

print "\n";

}

sub Zones()

{

my @zones = $telnet->cmd("zonestatus");
my $zonecnt = $#zones;

for($i=1;$i<$zonecnt;$i++)
	{
		print $zones[$i];
	}

print "\n";

}
Reply With Quote