#! /usr/bin/perl -w use lib qw(MYLIBPATH); use Net::Telnet; ($hostname, $username, $password, $supw, $newuser, $newpw) = @ARGV; $t = Net::Telnet->new( Timeout => 10, Host => $hostname ); $t->login($username, $password); $t->print("su -"); $t->waitfor('/assword:/'); $t->print("$supw"); $t->waitfor('/#/'); $t->print("passwd $newuser"); $t->waitfor('/assword: /'); $t->print("$newpw"); $t->waitfor('/new Password:/'); $t->print("$newpw"); $t->waitfor('/successfully changed/'); print "Change password of $newuser@$hostname successfully completed.n"; $t->close; |
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |