K_M_McMahon has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, thanks in advance for any help you can give me.

I have been working on a script using Net::Telnet. if I use
cmd()
it times out if I want to give it some other response since it never gets the expected prompt back. How do I tell it to look for a different prompt (if only temporarily) and then to look for the normal shell prompt after the next command?

Thanx!
-Kevin

Replies are listed 'Best First'.
Re: Net::Telnet question
by NetWallah (Canon) on Feb 25, 2004 at 04:39 UTC
    From Net::Telnet documentation:

    $prev = $obj->prompt($matchop);
    This method sets the pattern used to find a prompt in the input stream. It must be a string representing a valid perl pattern match operator. The methods login() and cmd() try to read until matching the prompt. They will fail with a time-out error if the pattern you've chosen doesn't match what the remote side sends.

    With no argument this method returns the prompt set in the object. With an argument it sets the prompt to $matchop and returns the previous value.

    The default prompt is '/[\$%#>] $/'

    Always use single quotes, instead of double quotes

    "Experience is a wonderful thing. It enables you to recognize a mistake when you make it again."
      Thanx! That worked and my script is done!

      -Kevin