#!/usr/bin/perl use strict; use IO::Pty; use Expect; use Net::OpenSSH; my $host = '10.0.0.1'; my @cmd = ('sh run', 'sh ver'); my $ssh = Net::OpenSSH->new($host); my ($pty, $pid) = $ssh->open2pty(@cmd) or die "unable to run remote command @cmd"; my $expect = Expect->init($pty);