I am having a odd problem with PERL EXPECT. The routine I created is a simple routine to telnet to an IP Address. The routine works - as expected when run from the UNIX command line.

When I try and call the routine from PHP - via the exec(), shell_exec() or system() function - the routine doesn't work. The issue I am seeing - when spawning the routine from PHP is that the INPUT BUFFER (where the MATCH occurs) does not seem to "fully" update with the data received from the server I am logging into.

Example: Running routine from PHP - this is the output produced with EXP_INTERNAL set to "1":
spawn id(5): Does `Trying 10.13.81.123...\r\r\nConnected to coveaux.at +m.ca (10.13.81.123).\r\r\nEscape character is \'^]\' .\r\r\n' match: pattern #1: -re `login:'? No. Waiting for new data (50 seconds)... TIMEOUT
Same routine from UNIX shell - this is the output produced with EXP_INTERNAL set to "1": (this is the expected output)
spawn id(3): Does `Trying 10.13.81.123...\r\r\nConnected to coveaux.at +m.ca (10.13.81.123).\r\r\nEscape character is \'^]\'.\r\r\n\r\n\r\nSu +nOS 5.8\r\n\r\r\n\r+------------------------------------------------- +----------------------+\r\n| WARNING + |\r\n| -- +----- |\r\n| + |\r\n| The programs and + data stored on this system are licensed to or are |\r\n| private +property of this company and are lawfully available only to |\r\n| +authorized users for approved purposes. Unauthorized access to any + |\r\n| program or data on this system is not permitted, and any unau +thorized |\r\n| access beyond this point may lead to prosecution. Thi +s system may be |\r\n| monitored at any time for operational reasons +, therefore, if you are |\r\n| not an authorized user, + |\r\n| DO NOT ATTEMPT TO LOG IN. + |\r\n| + |\r\n| + Avertissement |\r\n| + ------------- |\r\ +n| + |\r\n| Les programmes et les données stockés dans ce système sont + visés par |\r\n| une licence ou sont propriété privée de cette comp +agnie et ils ne sont|\r\n| accessibles légalement qu\'aux usagers aut +orisés a des fins autorisées.|\r\n| Il est interdit d\'y accéder sans + autorisation, et tout accès non |\r\n| autorisé au dela de ce p +oint peut entrainer des poursuites. Le système|\r\n| peut en tout tem +ps faire l\'objet d\'une surveillance. Si vous n\'êtes |\r\n| pas u +n usager autorisé, |\r\ +n| N\'ESSAYEZ PAS D\'Y ACCÉDER. + |\r\n+--------------------------------------------------------- +--------------+\r\nlogin: ' match: pattern #1: -re `login:'? YES!!
Can anyone provide some help -- identifying any further debugging or a hint as to what could be happening.

Platform routine is running on: Solaris 10, running PERL 5.8.7 with appropriate libraries. Expect.pm module -> V1.20 Apache/2.2.2 (Unix) mod_ssl/2.2.2 OpenSSL/0.9.8b PHP/5.2.5


In reply to PHP with PERL EXPECT by angelov

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.