Re: Help Required using NET::TELNET Module ??
- From: mark1.thompson45@xxxxxxxxxxxxxx
- Date: 29 Dec 2005 04:31:37 -0800
you ae correct, I would like the connection to machine B to originate
from machine A and not from the machine where the script is executed
from. I have attached the code if it will help, it basically loops
through a list of machines executing the 'telnet' command:-
open (HOSTS, "D:\\Documents and Settings\\801825642\\My
Documents\\tom1.txt");
while (my $line = <HOSTS>)
{
if ($line =~ m/--/)
{
#print "Comment Line Only\n";
} else {
@Data = split(":", $line);
$uid = $Data[2];
$pwd = $Data[3];
chomp $Data[6];
## check if a jumpastart server is required
if ($Data[4] ne '')
{
$jump_host = $Data[4];
$uid = $Data[5];
$pwd = $Data[6];
jump_start();
} else {
$jump_host = $Data[1];
Telnet_To_Device();
}
}
}
close(HOSTS);
create_csv();
create_webpage();
exit 0;
sub Telnet_To_Device
{
if ($jump == 0)
{
#print "\n\nTELNET CONNECTION EXISTS\n\n";
$script = new Net::Telnet ( Timeout=>5, Errmode=>'return', Prompt =>
'/[\$?>:#\]] *$/');
} else {
$script = new Net::Telnet ( Timeout=>5, Errmode=>'return', Prompt
=> '/[\$?>:#\]] *$/');
}
#$script->dump_log(@Data[0]."debug.log");
#$script->input_log('STDERR');
if (!($script->open($jump_host))) {
print "FAILED TO CONNECT TO $Data[0]\n";
return;
} else {
#print "\n\n>>$uid<-->$pwd<<\n\n";
print "\n\n$Data[0]:$Data[4]\n";
if ($jump)
{
#print "DO NOT ADD TO HASH - AS ONLY JUMPSTART\n";
} else {
$Output{$Data[0]} = "$Data[1],$Data[0],";
}
sleep 1;
$script->waitfor('/login:/i');
$script->print($uid);
sleep 1;
$script->waitfor('/password:/i');
my ($Before,$After) = $script->print($pwd);
sleep 1;
#print "B=$Before <==> A=$After\n";
#----------> check password is correct <-----------#
my ($Before,$After) = $script->waitfor('/Do you/');
#print "B=$Before <--> A=$After\n";
#sleep 5;
if ($After =~ m/do you understand/i)
{
print "IN SECURITY...\n";
$script->print('Y');
if ($Data[2] =~ m/nsg/i)
{
print "IN NSG...\n";
sleep 0.5;
$script->waitfor('/Please hit/i');
#print "B=$Before <==> A=$After\n";
$script->print('\n'); # nsg accounts - carriage return
sleep 0.5;
$script->waitfor('/[\$?>:#\]] *$/');
#print "B=$Before <==> A=$After\n";
} else {
print "NOT NSG ACCOUNT...\n";
sleep 0.5;
my ($Before,$After) = $script->waitfor('/[\$#] $/');
#print "B=$Before <==> A=$After\n";
}
} else { # straight to box prompt
#sleep 2;
print "NO WARNING...\n";
my ($Before,$After) = $script->waitfor('/[\$?>:#\]] *$/');
#my ($Before,$After) = $script->waitfor('/[\$%#>)/');
#print "B=$Before <==> A=$After\n";
}
if ($jump)
{
#print "Going from TELNET to JUMP\n";
return;
} else {
omnihome();
uname();
box_type();
procmon();
logmon();
netbackup();
webtop();
impact();
rad();
#--------------------------------------#
trap_dest();
osmf_tools();
disk_space();
omnibus();
disk_size();
$script->print('exit');
}
}
}
.
- Follow-Ups:
- Re: Help Required using NET::TELNET Module ??
- From: mark1 . thompson45
- Re: Help Required using NET::TELNET Module ??
- References:
- Help Required using NET::TELNET Module ??
- From: mark1 . thompson45
- Re: Help Required using NET::TELNET Module ??
- From: Gratemyl
- Help Required using NET::TELNET Module ??
- Prev by Date: Re: Help Required using NET::TELNET Module ??
- Next by Date: Re: Help Required using NET::TELNET Module ??
- Previous by thread: Re: Help Required using NET::TELNET Module ??
- Next by thread: Re: Help Required using NET::TELNET Module ??
- Index(es):
Relevant Pages
|
|