Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am changing password on multiple unix system .

Status
Not open for further replies.

bolobaboo

MIS
Aug 4, 2008
120
US
I am planning to change password for my account on multiple unix system. I am using following script ..can any body fix any bug in it ? I am brand new to pearl. Only i know that below code shoule be save as change_pw.pl and wada !!



use strict;
use IO::File;
use DBI;
use Net::Telnet;

# set the required variables

my (@list,$server_list,$count);
my ($old_passwd,$new_passwd,$remote_login);
my ($DB_server,$DB_user,$DB_passwd,$telnet,$output);

# Get the required login and passwords

print "Enter the remote login :\n";
$remote_login = <>;
print "Enter the old password :\n";
$old_passwd = <>;
print "Enter the new password (Remember it should differ atleast in 3 CHAR than the old pas
swd) :\n";
$new_passwd = <>;

# Compare the Old and new password, if same exit
# else open the list and for each server on the list
# enter the remote_login and the old_passwd to login to the box and use the new_passwd to c
hange it

if ("$old_passwd" eq "$new_passwd")
{
print "Old and new password are same \n";
exit;
}
else
{
open(server_list,".servers") || die "couldn't open the file!\n";
@list = <server_list>;
$count = 0;
foreach $DB_server(@list){
$telnet = new Net::Telnet (Timeout =>10,
Errmode => 'die');
$telnet->open('dba1-sun');
$telnet->login("$remote_login","$old_passwd");
$telnet->cmd('passwd');
#$telnet->waitfor ('/\$ $/i');
$telnet->waitfor('/Enter existing login password: $/i');
$telnet->print("$old_passwd");
$telnet->waitfor('/New Password: $/i');
$telnet->print("$new_passwd");
$telnet->waitfor ('/Re-enter new Password: $/i');
$telnet->print("$new_passwd");
$output = $telnet->waitfor('/\$ $/i');
print $output;
$count++;
}
close(server_list);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top