php.net |  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
31 + 24 = ?
Subscribe to this entry?

 
 [2009-09-09 07:48 UTC] bug at 11k dot dk
Description:
------------
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?

Reguards
Klaus

Reproduce code:
---------------
<?
function telnetbackup($ip,$un,$pw) {
  $stream = expect_popen("telnet $ip");
  fwrite ($stream, "$un\n$pw\n");
  sleep(1);
  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];
      break;

    case EXP_TIMEOUT:
      break;

    case EXP_EOF:
      break;

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

?>


Expected result:
----------------
More lines matched.

Actual result:
--------------
Fewer lines then expected.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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 
extension.
 [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?

BR
Benjamin
 [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
http://pecl.php.net/get/expect

Please use new PHP.ini parameter "expect.match_max"
 [2011-01-23 22:58 UTC] faustovaz at gmail dot com
Hi,
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?

Thanks,
Fausto.
 [2011-01-24 01:09 UTC] spektom at gmail dot com
Please read this to get more sense about this parameter: http://wiki.tcl.tk/9407
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 20:01:30 2024 UTC