|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58854 Limit on match
Submitted: 2009-09-09 07:48 UTC Modified: 2011-01-24 01:09 UTC
From: bug at 11k dot dk Assigned:
Status: Closed Package: expect (PECL)
PHP Version: 5.2.0 OS: Linux 2.6.18-6-686
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: bug at 11k dot dk
New email:
PHP Version: OS:


 [2009-09-09 07:48 UTC] bug at 11k dot dk
I think there is a limit on the length on witch the match is done. I use expect to do telnet backup of cisco routers, and now i want to use expect for php instead of perl.

When i match what i want to return, i only get about 298 lines or 7.080 bytes, is there some kind of limit on what expect matches on?


Reproduce code:
function telnetbackup($ip,$un,$pw) {
  $stream = expect_popen("telnet $ip");
  fwrite ($stream, "$un\n$pw\n");
  fwrite ($stream, "sh run\n");
  $cases = array (
    array ("(.*)end\r\n", END, EXP_REGEXP)

  switch(expect_expectl ($stream, $cases, $match)) {
    case END:
      return $match[0];

    case EXP_TIMEOUT:

    case EXP_EOF:

      die ("Error has occurred!\n");
echo "<br>\n<pre>".telnetbackup("","admin","password")."</pre>\n";


Expected result:
More lines matched.

Actual result:
Fewer lines then expected.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-22 11:36 UTC] spektom at gmail dot com
Yes, I see some limitation in a capture group length (I get 
another numbers, though). I'm checking whether this is a 
limitation of libexpect or there's some issue in PHP 
 [2010-12-12 11:09 UTC] benjamin dot lugger at gmx dot net
Hi togethr,

I also run into that problem. Is there a solution for this problem?

 [2011-01-09 03:51 UTC] spektom at gmail dot com
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at

Please use new PHP.ini parameter "expect.match_max"
 [2011-01-23 22:58 UTC] faustovaz at gmail dot com
setting the expect_match_max solved the same problem for me, 
but, until now, i don't understand what kind of value i have 
to set to this parameter.
I tried a lot of numbers, some work, some doesn't. 
Is expect_match_max parameter related to the length of the 
pattern that i want to match?
What kind of use this parameter has?

 [2011-01-24 01:09 UTC] spektom at gmail dot com
Please read this to get more sense about this parameter:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 04:01:28 2024 UTC