http://www.perlmonks.org?node_id=1038421

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

Hi,

Of course I need write some Telnet code in perl but i have some problems. My system support diffrent types of prompt with different functionality, so:

1. login prompt:

This computer resource is private property. Unauthorized access, misuse, and misappropriation of resources is prohibited by law. hapWibbSc2 login: root Password: Last login: Tue Jun 11 12:04:37 on ttyS0 root@hapWibbSc2:~#

2. 'linux' kind prompt root@hapWibbSc2:~#

3. agent prompt:

root@hapWibbSc2:~# cli Starting Agent CLI hapWibbSc2#

How to detect in which prompt am I, because there is different types of command in every.

And second problem when I grabbing out put of command sometime if output is longer it print "--More--" waiting for <space> key from user to print rest how to decect is and send <space> and grab rest of output.

i.e.

...pciConflictResolutionMode preview sendSortedEutraNeighbors true sen +dSortedCdma2000Neighbors true TinterFreqAnrMeasDuration 100 TreportStrongestCellsForSonEhrpd 1 +00 TreportStrongestCellsForSonOnex 100 sonAppLogEn able true anrModeEUtran disabled anrModeEhrpd disabled anrModeOnex dis +abled nrtMaxSizeEUtran 134 nrtMaxSizeEhrpd 134 nrt MaxSizeOnex 134 anrScoreOnexMin 5 anrScoreOnexMax 10 anrSco --More-- reOnexThresholdMax 20

Anyhelp will be grate!

Replies are listed 'Best First'.
Re: Net::Telnet different prompts
by Anneq (Vicar) on Jun 12, 2013 at 11:21 UTC

    Maybe you can use shell commands to change the prompt to what your script expects.

    For your second problem, if you tell us what command you are using that issues the --more-- prompt, perhaps someone could help you with that command, to ensure that it doesn't happen.

    Anne