#!/usr/bin/perl #use strict; use warnings; use Expect; my $command = "ssh"; my @parameters = ('10.10.10.10', 'uptime'); my $exp = Expect->spawn($command, @parameters) or die "Cannot spawn $command: $!\n"; $exp->expect( [ qr/yes/ => sub { my $exp = shift; $exp->send("yes\n"); exp_continue; }], [qr/assword/i => sub { my $exp = shift; $exp->send("1234\n"); exp_continue; }] )