|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34812 socket_write will not write a string ending in 0 "Zero"
Submitted: 2005-10-10 15:55 UTC Modified: 2005-10-29 01:00 UTC
From: shane at 71software dot com Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 5.1.0RC1 OS: Windows XP
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: shane at 71software dot com
New email:
PHP Version: OS:


 [2005-10-10 15:55 UTC] shane at 71software dot com
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);

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


Actual result:
xxxxxxx#terminal length ***************************************************************************************

NOTE: 'xxxxxxx#' being the router prompt


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-11 21:03 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

 [2005-10-17 15:19 UTC] shane at 71software dot com
I am not sure that I can reproduce the intended result without a router in 20 lines or less. What should I do?
 [2005-10-17 15:35 UTC]
We can't reproduce it either.
Please reopen the report when you have a short but complete reproduce script or just more info about it.
 [2005-10-17 15:58 UTC] shane at 71software dot com
If I give you access to the script and a router to run the script on will that suffice?
 [2005-10-17 15:58 UTC] shane at 71software dot com
The bug is not bogus.
 [2005-10-19 13:36 UTC] franz dot hofbauer at gmail dot com
Perhaps it's a Cisco-IOS-Bug?

Have you already checked the network-traffic with a sniffer (e.g. Ethereal), which bytes are exactly sent to the router by your PHP-Script?
 [2005-10-20 15:36 UTC] shane at 71software dot com
I have mostly ruled the Cisco IOS bug out because there are several Perl scripts that issue the 'terminal length 0' command. I will sniff the traffic though because that sounds like a great way to get some definitive answers. Thank you. I will post once I have it.
 [2005-10-29 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 01:01:28 2024 UTC