Julio -
I've updated your script a little and I believe this is what you're looking to do. Since it's looking for a specific "$match" string, password prompt and "---more" string, this will only work on JunOS. You can modify it for other vendors - or get cute with regex and make it multi-vendor.
#!/usr/bin/perl
use Expect;
my $access_protocol = 'ssh';
my $host = 'myhost.mycompany.com';
my $timeout = 15;
my $username = 'svc_network_readonly';
my $password = 'sc00byd00byD00';
$Expect::Log_Stdout = 0;
my @commands = ("show virtual-chassis", "show version", "show arp no-r
+esolve", "show ethernet-switching table", "exit");
my $exp = Expect->spawn("$access_protocol -l $username $host") or die
+"Can't connect to $host: $!\n";
my $match="^$username\@$host. ";
$exp->expect ($timeout,
['^\-\-\-.more', sub {
$x = $exp->before();
print "$x";
$exp->send(" ");
exp_continue;
}],
[ qr /$username\@$host\'s password: /, sub {
$exp->send("$password\n");
exp_continue;
}],
[ $match, sub {
my $cmd=shift(@commands);
$x = $exp->before();
print "$x";
$exp->send("$cmd\n");
exp_continue;
}],
['timeout', sub {
print "A timeout has occurred - no match found\n";
}],
'-re', '] $');