php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62982 php [options] [-B <begin_code>] -R <code> [-E <end_code>]
Submitted: 2012-08-31 15:06 UTC Modified: 2012-08-31 18:17 UTC
From: luis dot pessoa67 at ibest dot com dot br Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.4Git-2012-08-31 (Git) OS: Windos 7 SP1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: luis dot pessoa67 at ibest dot com dot br
New email:
PHP Version: OS:

 

 [2012-08-31 15:06 UTC] luis dot pessoa67 at ibest dot com dot br
Description:
------------
---
From manual page: http://www.php.net/features.commandline.options
---

Why Didn't it work?

c:\php>dir /aa /b | php -B '$l=0;$i=1;' -R '$l+=count(@file($argv[$i++]));' -E 'echo "files: $l\n";'

Parse error: syntax error, unexpected end of file in Command line begin code on
line 1

Parse error: syntax error, unexpected ''echo' (T_ENCAPSED_AND_WHITESPACE) in Com
mand line end code on line 1

c:\php>php -v
PHP 5.4.5 (cli) (built: Jul 18 2012 22:25:51)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies


Test script:
---------------
c:\php>dir /aa /b | php -B '$l=0;$i=1;' -R '$l+=count(@file($argv[$i++]));' -E 'echo "files: $l\n";'


Expected result:
----------------
files: XXXXX

Actual result:
--------------
Parse error: syntax error, unexpected end of file in Command line begin code on
line 1

Parse error: syntax error, unexpected ''echo' (T_ENCAPSED_AND_WHITESPACE) in Com
mand line end code on line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-31 15:47 UTC] rasmus@php.net
Works fine for me on Linux:

> ls | php53 -B '$l=0;$i=1;' -R '$l+=count(@file($argv[$i++]));' -E 'echo "files: 
$l\n";'
files: 449

Weird Windows thing?
 [2012-08-31 15:47 UTC] rasmus@php.net
-Status: Open +Status: Feedback
 [2012-08-31 16:15 UTC] ab@php.net
On windows shell you cannet use single quotes to wrap strings, use double quotes for that

dir /aa /b | Debug_TS\php.exe -B "$l=0;$i=1;" -R "$l+=count(@file($argv[$i++]));" -E "echo 'files: ' . $l;"

That's the basic windows cmd behaviour.
 [2012-08-31 16:15 UTC] ab@php.net
-Status: Feedback +Status: Not a bug
 [2012-08-31 18:17 UTC] luis dot pessoa67 at ibest dot com dot br
Copy-paste pitfalls! Case Closed.

tks Rasmus n Ab!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 05:01:34 2025 UTC