From: shane at 71software dot com
Operating system: Windows XP
PHP version: 5.1.0RC1
PHP Bug Type: Sockets related
Bug description: socket_write will not write a string ending in 0 "Zero"
Description:
------------
I am using sockets to log in to a Cisco router. I need to issues the
command "terminal length 0". The 0 must return a FALSE or NULL status to
socket_write or maybe socket_read is what is actually returning false I am
not sure. But it will not work in Binary, ASCII, OCTAL, HEX anything.
Reproduce code:
---------------
$IosCmdExec = 'terminal length 0' . "\n";
socket_write($socket, $IosCmdExec, strlen($IosCmdExec));
$makeCaptureFile = 'C:\rtrconfig\config.txt';
$captureFile = fopen($makeCaptureFile,'a');
$out = '';
while ($out = socket_read($socket, 1024)){
ereg_replace("\r", ' ', $out);
fwrite($captureFile, $out);
}
$sep =
'***************************************************************************************';
fwrite($captureFile, $sep);
socket_shutdown($socket, 2);
socket_close($socket);
Expected result:
----------------
I expect the writing of 'terminal length 0' to the Cisco CLI. It works
fine as long as the digit is not 0. 1-512 etc.
xxxxxx#terminal length 512
Building configuration...
Current configuration : 26921 bytes
!
! Last configuration change at 07:00:37 CDT Tue Jun 28 2005 by amschultz
! NVRAM config last updated at 06:38:49 CDT Mon Jun 20
!
version 12.2
no service pad
service timestamps debug datetime msec localtime show-timezone
service timestamps log datetime msec localtime show-timezone
service password-encryption
service compress-config
!
hostname xxxxxx
!
logging buffered 512000 debugging
aaa new-model
aaa authentication login default group tacacs+ local
etc......
Actual result:
--------------
xxxxxxx#terminal length
***************************************************************************************
NOTE: 'xxxxxxx#' being the router prompt
--
Edit bug report at http://bugs.php.net/?id=34812&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34812&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34812&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34812&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34812&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34812&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34812&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34812&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34812&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34812&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34812&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34812&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34812&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34812&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34812&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34812&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34812&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34812&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34812&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34812&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34812&r=mysqlcfg