in reply to Re^2: Net telnet Cisco Login
in thread Net telnet Cisco Login
Well, first I think you shouldn't be using login with waitfor. You'll use print because waitfor captured the prompt and I don't think login will see it after that.
Second, you missed the whole point of using a regex there. If you read the Net::Telnet documentation on waitfor, you'll see that
gives you the string that matched in $match. So, if you use a regex like /(Password|Username)/ and a list assignment (again, I got this straight from the documentation for the module), then $match tells you whether you need to $obj->print a password or username string. Naturally if you print a username, you should then waitfor the password prompt and print the password. login attempts to simplify this stuff, but it's extremely picky about what it expects to see.my ($prematch, $match)= $obj->waitfor($matchop);
Your code needs to do the job of login, not try to work alongside it. A direct quote from the login section of Net::Telnet: "Consider using a combination of print() and waitfor() as an alternative to this method when it doesn't do what you want, e.g. the remote host doesn't prompt for a username."
|
|---|