#!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; use Expect; my $logs = "logs"; open(LOG,'>>',"$logs") or die "can't logs $!\n"; my $domain = 'domain.com'; my @host = qw/host/; foreach my $host (@host) { my $cmd = "passwd user1"; my $sshost = join('.', $host, $domain); my $ssh = Net::SSH::Perl->new("$sshost"); $ssh->login('root'); $ssh->debug(); my ($stdout, $stderr, $exit) = $ssh->cmd($cmd); print LOG $stdout,"\n"; }