Re: Help Required using NET::TELNET Module ??



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');
}
}
}

.



Relevant Pages

  • Jumpstart: syntax error and trying to load from /cdrom media, which disk to use for Solaris 8 image
    ... I'm not sure if I need to use that disk or the Solaris 8 Installation ... Using RPC Bootparams for network configuration information. ... Using finish script: diag_drv.fin ... Executing JumpStart preinstall phase... ...
    (SunManagers)
  • QUESTION: shared libraries
    ... how would I create a package easy-to-install for a new user? ... we could use a script to install the package. ... I have seen some scripts executing from a ... Gouvernement du Canada / Government of Canada ...
    (comp.os.linux.development.apps)
  • QUESTION: shared libraries
    ... how would I create a package easy-to-install for a new user? ... we could use a script to install the package. ... takes root privileges to do so. ... I have seen some scripts executing from a ...
    (alt.os.linux.redhat)
  • QUESTION: shared libraries
    ... how would I create a package easy-to-install for a new user? ... we could use a script to install the package. ... takes root privileges to do so. ... I have seen some scripts executing from a ...
    (comp.os.linux.development.system)
  • Re: Very big infrastructure - Please help
    ... if executing where principal is defined, ... > 1)I must add a user from the root domain to Cert Publishers group on every ... > child domain- to have the property permission "write user certificate" on ... > every child domain.How to do this with a script or anything else? ...
    (microsoft.public.windows.group_policy)