in reply to Expect.pm dealing with STDOUT

The previous respondant was actually correct; you need to create an expect object and then use that object to do things. I don't claim great expertise in it either, but I have been asked to make things work in Perl Expect. What I'll offer is a bit of a code snippet where the script is logging into a router via ssh and then looking at the prompt to help determine the type of the router.

my $exp = new Expect; $exp->raw_pty(1); $exp->log_stdout(0); # $exp->log_stdout(1); # uncomment for debugging $exp->log_file($logfile); my $host = "$r\.domain\.com"; $exp->spawn("ssh -o StrictHostKeyChecking=no $user{$r}\@$host ") | +| die("Cannot spawn an ssh session within expect.\n"); $exp->expect($delay, [ 'assword:', sub { my $exp = shift; $exp->send("$pass{$r}\r"); exp_continue; } ], [ eof => sub { $exitcode = 1; } ], [ timeout => sub { $exitcode = 2; } ], [ '>', sub { my $exp = shift; $cisco = $false; $prompt = '>'; } ], [ '#', sub { my $exp = shift; } ],);