Thread Net::Telnet - Page-Modus (10 answers)
Opened by KPW at 2012-02-29 17:14

GwenDragon
 2012-02-29 17:57
#156514 #156514
User since
2005-01-17
14748 Artikel
Admin1
[Homepage]
user image
Code: (dl )
1
2
3
4
5
6
7
8
9
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 CPAN:Net::Telnet durchlesen.

https://metacpan.org/module/Net%3A%3ATelnet#What-To-Know-Before-Using
What 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#METHODS
waitfor - 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)

View full thread Net::Telnet - Page-Modus