I am passing an scp command in Expect->spawn($command)
, I am also passing the password or password + OTP based on a $object->expect()
.
Could you let me know if there is a way to determine if the command has been run successfully ?
I'm trying $object->after()
, but it's giving the password prompt which is the previous $object->expect()
also explored $object->exitstatus()
, it'll be empty since the object is not exited.
my $expect_obj = new Expect;
$expect_obj->log_stdout(0);
my $spawn = $expect_obj->spawn(split/\s+/, "scp $src $dest");
my $pos = $expect_obj->expect(60,
[qr/password.*: $/, sub {my $self = shift; $self->send("$pass\n")}],
);
How do I determine if the command is successful ?