Mit telnet->print das Kommando senden
solange:
Zeile mit telnet->getline einlesen
Prüfen ob '---More---' in Zeile vorkommt
Wenn ja dann mit telnet->print \n senden
Prüfen ob Prompt in Zeile vorkommt
wenn ja dann Ende:
weiter nach solange:
Ende:
Für den Code einfach mal
Net::Telnet durchlesen.
https://metacpan.org/module/Net%3A%3ATelnet#What-To-Know-Before-UsingWhat To Know Before Using
All output is flushed while all input is buffered. Each object contains its own input buffer.
The output record separator for print() and cmd() is set to "\n" by default, so that you don't have to append all your commands with a newline. To avoid printing a trailing "\n" use put() or set the output_record_separator to "".
The methods login() and cmd() use the prompt setting in the object to determine when a login or remote command is complete. Those methods will fail with a time-out if you don't set the prompt correctly.
Use a combination of print() and waitfor() as an alternative to login() or cmd() when they don't do what you want.
Übrigens sollte das Pattern für waitfor in '' eingeschlossen werden, wenn ich die Doku so lese:
https://metacpan.org/module/Net%3A%3ATelnet#METHODSwaitfor - wait for pattern in the input
(...)
To avoid unexpected backslash interpretation, always use single quotes instead of double quotes to construct a match operator argument for prompt() and waitfor() (e.g. '/bash\$ $/'). If you're constructing a DOS like file path, you'll need to use four backslashes to represent one (e.g. '/c:\\\\users\\\\bill>$/i').
Dann nochmal fragen, wenn Problem ungelöst oder kein Code verstanden wurde. ;)
Last edited: 2012-02-29 18:05:05 +0100 (CET)