in reply to Expect Question
Update: Fixed#!/usr/bin/perl use strict; use warnings; use Net::SSH::Expect; use constant CMD => 'ls -l'; $Expect::Debug => 3; $Expect::Do_Soft_Close => 1; my $ssh = Net::SSH::Expect->new ( host => "somehost", user => 'someuser', password => 'password', log_stdout => 1, raw_pty => 1, timeout => 5 ); eval { my $login_output = $ssh->login(); if ($login_output !~ /Welcome/) { die "Login has failed. Login output was $login_output"; } }; my $spawn = new Expect; $spawn->log_file("log.txt", "w"); $spawn->cmd(CMD); $spawn->soft_close; exit(0);
|
|---|