in reply to storing return value from Expect

You want to store the value from your expect, not the send. The following is untested:
$ssh->send("ping 172.16.10.29\r"); #notice \r here; I think it's prefe +rred over \n in expect my $stuff = $ssh->expect(10, qr 'wall#');
If this doesn't work, a perldoc Expect might be in order.

thor

Replies are listed 'Best First'.
Re: Re: storing return value from Expect
by belkajm (Beadle) on Aug 09, 2002 at 18:20 UTC
    unfortunately, expect doesn't work this way. according to the docs on sourceforge:

    If called in a scalar context, expect() will return the position of the matched pattern within $match_patterns, or undef if no pattern was matched. This is a position starting from 1, so if you want to know which of an array of @matched_patterns matched you should subtract one from the return value.

    If called in an array context expect() will return ($matched_pattern_position, $error, $successfully_matching_string, $before_match, and $after_match).

    Also, please note that \r might not work with some programs when raw mode is activated. Normally expect does cr->lf translation, but this is disabled in raw mode. From a brief read of the docs, i think they are suggesting that \n is actually the better choice.