this is a repost.. but i got no replys before.. and am just looking for some help.. if anyones out there.
i am currently creating a script that uses $telnet->login($user,$passwd) to login and then run the passwd command to change the password.. but the script bombs out if the current password is wrong for that server.. does anyone have any ideas to help me check for a bad login or password so that it will skip that host and move on to the next? heres some of the code: THANKS
if ($go eq "true"
{
print "-------------------------------\nTrying to connect to -- $host...\n";
$ping = `/usr/sbin/ping $host 3`;
if ($ping =~/alive/) {
$telnet = new Net::Telnet (Timeout=>15, Prompt=>'/[\$%:#>] *$/' );
$telnet->open($host);
$telnet->login($username,$curpasswd1);
print "Connection established -- $host...\n";
$line = $telnet->lastline;
#if ($telnet=> 'New') {
#if the password is expired
print "This is line $line\n";
if($line =~ /Please/) {
print "expired aix\n";
$telnet->print($newpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/[\$%:#>] *$/');
$telnet->cmd('');
}
elsif($line =~ /assword/) {
print "expired sun hp\n";
$telnet->print($curpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/[\$%:#>] *$/');
$telnet->cmd('');
}
else {
print "not expired\n";
$telnet->print('passwd');
$telnet->waitfor('/password:/');
$telnet->print($curpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/[\$%:#>] *$/');
$telnet->cmd('');
}
$telnet->close;
print "password change successful on $host...\n";
} else {
print "** $host not pingable, aborted password change for $host **\n";
}
}
}
}
}
print "-------------------------------\n"
i am currently creating a script that uses $telnet->login($user,$passwd) to login and then run the passwd command to change the password.. but the script bombs out if the current password is wrong for that server.. does anyone have any ideas to help me check for a bad login or password so that it will skip that host and move on to the next? heres some of the code: THANKS
if ($go eq "true"
print "-------------------------------\nTrying to connect to -- $host...\n";
$ping = `/usr/sbin/ping $host 3`;
if ($ping =~/alive/) {
$telnet = new Net::Telnet (Timeout=>15, Prompt=>'/[\$%:#>] *$/' );
$telnet->open($host);
$telnet->login($username,$curpasswd1);
print "Connection established -- $host...\n";
$line = $telnet->lastline;
#if ($telnet=> 'New') {
#if the password is expired
print "This is line $line\n";
if($line =~ /Please/) {
print "expired aix\n";
$telnet->print($newpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/[\$%:#>] *$/');
$telnet->cmd('');
}
elsif($line =~ /assword/) {
print "expired sun hp\n";
$telnet->print($curpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/[\$%:#>] *$/');
$telnet->cmd('');
}
else {
print "not expired\n";
$telnet->print('passwd');
$telnet->waitfor('/password:/');
$telnet->print($curpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/assword/');
$telnet->print($newpasswd1);
$telnet->waitfor('/[\$%:#>] *$/');
$telnet->cmd('');
}
$telnet->close;
print "password change successful on $host...\n";
} else {
print "** $host not pingable, aborted password change for $host **\n";
}
}
}
}
}
print "-------------------------------\n"