|
Posted by comp.lang.tcl on 12/02/06 00:48
Bryan Oakley wrote:
> comp.lang.tcl wrote:
>
> > When I call it via command-line:
> >
> > php -q /home/ppowell/web/blah.php << '<?xml version="1.0"
> > encoding="utf-8" ?><blah><foo id="1"></foo></blah>'
> >
> > This happens:
> >
> > /users/ppowell -->php -q /home/ppowell/web/blah.php << '<?xml
> > version="1.0" encoding="utf-8" ?><blah><foo id="1"></foo></blah>'
> >
> > [and it just sits there for input until I hit CTRL-C]
> >
>
> '<<' has a different behavior in a shell than it does in Tcl. You can't
> use them the same way.
>
> Using '<<' from a bash shell is what is called a "here document". Here's
> one description:
>
> http://www.faqs.org/docs/bashman/bashref_42.html#SEC42
Ok an update:
I fixed the PHP script (you were right, there were syntax errors after
all, but I was unable to detect them):
set php {<?
error_reporting(E_ALL & ~E_NOTICE);
require_once('functions.inc.php');
$xml = preg_replace('/(>)[\n\r\\s\t]+(<)/', '$1$2',
@file_get_contents('php://stdin'));
$parser = @xml_parser_create();
@xml_parse_into_struct($parser, $xml, $xmlArray, $tags);
@xml_parser_free($parser);
for ($i = 1; $i < @sizeof($xmlArray) - 1; $i++) {
foreach ($xmlArray[$i]['attributes'] as $attr => $val) {
foreach (array(&$attr, &$val) as $field) {
$field = str_replace('{', '{', str_replace('}',
'}', $field));
$tclList .= (preg_match('/[\s\t]+/', $field)) ? '{' .
$field . '} ' : "$field ";
}
}
}
echo trim($tclList);
?}
global valPHPPath
if {![info exists valPHPPath]} {
if {![array exists env]} { global env }
source cgi_globals.tcl
global valPHPPath
}
if {[catch [exec $valPHPPath -q /home/ppowell/web/blah.php <<
$contents] result]} {
puts stderr "error involving PHP execution: $result"
exit 2;
} else {
return $result
}
Produces the same error and apparently hangs up when it tries to read
from stdin (is there a stdin size limit?), so it is no longer a TCL
problem at this point
Phil
Navigation:
[Reply to this message]
|