#!/usr/bin/perl # # Change console passwords on a 3Com switch # # Jim Trocki # # $Id: 3cpasswd,v 1.3 2000/07/05 20:44:05 trockij Exp $ # # Copyright (C) 1998 Jim Trocki # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # use A3Com::Sys; use Getopt::Std; use Data::Dumper; sub help; sub get_pw; getopts ("h", \%opt); help() if ($opt{"h"} || @ARGV == 0); $COMM = A3Com::Sys::get_password ("Write community: "); die "no community specified\n" if ($COMM =~ /^\s*$/); my %v = (); print "Type 'none' for no password, to not change\n"; $READ = get_pw ("Read login"); die "passwords differ\n" if (!defined $READ); if ($READ ne "") { $v{"read"} = $READ eq "none" ? "" : $READ; } $WRITE = get_pw ("Write login"); die "passwords differ\n" if (!defined $WRITE); if ($WRITE ne "") { $v{"write"} = $WRITE eq "none" ? "" : $WRITE; } $ADMIN = get_pw ("Admin login"); die "passwords differ\n" if (!defined $ADMIN); if ($ADMIN ne "") { $v{"adm"} = $ADMIN eq "none" ? "" : $ADMIN; } foreach $HOST (@ARGV) { my ($r, $v) = A3Com::Sys::console_password ( host => $HOST, community => $COMM, %v, ); if (!defined $r) { print "$HOST not changed: $v\n"; next; } print "$HOST passwords changed\n"; } sub help { print <