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
In reply to Matching prompt in Net::Telnet by kkarne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |