I'm using Expect to ssh. I want to know the Session ID of the spawned session. How do I do that?
This is my code:
my $addr = "10.101.10.102";
my $cmd = "ssh username@".$addr;
my $exp = Expect->spawn($cmd) or die "Cannot spawn command\n";
I'm using Expect to ssh. I want to know the Session ID of the spawned session. How do I do that?
This is my code:
my $addr = "10.101.10.102";
my $cmd = "ssh username@".$addr;
my $exp = Expect->spawn($cmd) or die "Cannot spawn command\n";
Copyright © 2021 Jogjafile Inc.
Have you tried using the
$exp->pid()method of Expect. the documentation for the Expect module says:I have tried this in a simple test to telnet to local host, and do a unix ps command to see the processes and also the
$exp->pid()command and they match.OUTPUT