kkarne has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to run a who command on a remote server using Net::Telnet
1. use Net::Telnet; 2. $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die',Input_Log= +>'out.txt',Prompt=>'/.*tstbld.*/'); 3. $telnet->open('seahawk'); 4. $telnet->login('tstbld', 'vilc0n'); 5. $telnet->cmd(String=>'cd /builds/htpc2003r1/base/menu', Prompt=>'/. +*htpc.*/'); 6. $prompt = '/pkmsqa/'; 7. print $telnet->cmd(String=>'who', Prompt=>$prompt);
When I see the actual output from line 7 in out.txt file, it shows all lines returned by who command. Basically the command prompt is returned twice, once before the results and once after the results
[/builds/htpc2003r1/base/menu] seahawk:>who pkmsqa pts/0 Nov 07 03:19 (10.80.12.176) tstbld pts/3 Nov 07 08:40 (10.80.12.176) tstbld pts/4 Nov 08 02:35 (10.80.12.154) pkmsqa pts/5 Nov 08 04:59 (10.80.12.154) [/builds/htpc2003r1/base/menu] seahawk:>
[/builds/htpc2003r1/base/menu] seahawk:>who
If I specify prompt = ‘/>/', it returns everything before the first occurrence of >
[/builds/htpc2003r1/base/menu] seahawk:
How do I specify prompt so that it returns me everything before the second > I tried /Z option, $& option, >& option but nothing works. The match is always being done with first occurrence and not the last occurrence.
Thanks, KK
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching prompt in Net::Telnet
by wjw (Priest) on Nov 08, 2006 at 21:45 UTC | |
by kkarne (Novice) on Nov 08, 2006 at 21:59 UTC | |
|
Re: Matching prompt in Net::Telnet
by wjw (Priest) on Nov 08, 2006 at 20:10 UTC | |
by kkarne (Novice) on Nov 08, 2006 at 20:26 UTC | |
by wjw (Priest) on Nov 08, 2006 at 20:37 UTC | |
by wjw (Priest) on Nov 08, 2006 at 20:51 UTC | |
by kkarne (Novice) on Nov 08, 2006 at 21:00 UTC | |
by kkarne (Novice) on Nov 08, 2006 at 21:48 UTC | |
|
Re: Matching prompt in Net::Telnet
by runrig (Abbot) on Nov 08, 2006 at 22:31 UTC | |
|
Re: Matching prompt in Net::Telnet
by quester (Vicar) on Nov 09, 2006 at 05:23 UTC | |
by kkarne (Novice) on Nov 11, 2006 at 18:54 UTC | |
|
Re: Matching prompt in Net::Telnet
by laceytech (Pilgrim) on Nov 09, 2006 at 18:00 UTC |