my ($pty, $pid) = $ssh->open2pty() # and empty command line invokes a shell! or die "unable to run remote shell"; my $expect = Expect->init($pty); $expect-> ...