| 
	
 | 
 Posted by comp.lang.tcl on 12/01/06 18:00 
Bryan Oakley wrote: 
> comp.lang.tcl wrote: 
> > Bryan Oakley wrote: 
> > 
> >>comp.lang.tcl wrote: 
> >> 
> >>>[TCL] 
> >>> 
> >>>set php {<? print_r("Hello World"); ?>} 
> >>>... 
> >>>[/TCL] 
> 
> >>If you're wanting to exec php and give it the contents of a variable on 
> >>stdin, try this: 
> >> 
> >>puts [exec php << $php] 
> >> 
> >>You need to make sure that "php" is a valid command file on your 
> >>machine, and that its location is in your PATH environment variable. 
> > 
> > 
> > Ok this is what I did: 
> > 
> > [TCL] 
> >  set contentsList [exec $valPHPPath << $php]; # $valPHPPath IS THE PATH 
> > TO "php" 
> > [/TCL] 
> > 
> 
> In the above, is $php the string you showed earlier or does it contain 
> something else? 
> 
> > And here is the error message I now get: 
> > 
> > Status: 404 X-Powered-By: PHP/4.4.4 Content-type: text/html No input 
> > file specified. child process exited abnormally while executing "exec 
> > $valPHPPath << $php" (procedure "XML_GET_ALL_ELEMENT_ATTRS" line 36) 
> > 
> 
> I'm not sure what the problem is, if all you say is true. When I type in 
> the equivalent, I get back "Hello World": 
> 
>      $ tclsh 
>      % set php {<? print_r("Hello World"); ?>} 
>      <? print_r("Hello World"); ?> 
>      % exec php << $php 
>      Hello World 
 
When I went into command-line and tried it (again I'm using HP-UX 
apparently): 
 
[quote] 
set php 
<? 
            error_reporting(E_ALL & ~E_NOTICE); 
            $xml = preg_replace('/(>)[\\n\\r\\\s\\t]+(<)/', '$1$2', 
$argv[1]); /* STRIP OUT WHITESPACE xml_parser_set_option() MIGHT MANGLE 
XML */ 
            $parser = @xml_parser_create(); 
            @xml_parse_into_struct($parser, $xml, $xmlArray, $tags); 
            @xml_parser_free_parser($parser); 
            for ($i = 1; $i < @sizeof($xmlArray) - 1; $i++) \{ 
             foreach ($xmlArray[$i]['attributes'] as $attr => $val) 
              $tclList .= $attr . ' \{' . str_replace('\{', '{', 
str_replace('\}', '}', $val)) . '\} '; /* ESCAPED CURLY BRACES FOR 
TCL LIST */ 
            \} 
            echo trim($tclList); 
          ?> 
% exec /usr/local/bin/php -q << $php 
<br /> 
<b>Warning</b>:  Unexpected character in input:  '\' (ASCII=92) state=1 
in <b>-</b> on line <b>7</b><br /> 
<br /> 
<b>Warning</b>:  Unexpected character in input:  '\' (ASCII=92) state=1 
in <b>-</b> on line <b>10</b><br /> 
child process exited abnormally 
 
[/quote] 
 
I realize I am getting PHP errors, so at this point I don't know if 
this is a TCL problem with the way I'm creating $php, or a PHP problem 
with the way TCL handles PHP.  So I believe cross-posting is essential 
for this to be solved at this point. 
 
> 
> So... the only conclusion I can draw is that your php command doesn't 
> work the same way as mine. That, or you're putting something different 
> in $php. Unfortunately I am not able to exactly duplicate your 
> environment since you're executing tcl from with a web page served by 
> some tcl-enabled web server, and I don't have that web server (what web 
> server is that, BTW?) 
 
Apache 2.0.53 
 
> 
> The only thing I can suggest at this point is that the problem is no 
> longer a Tcl problem but rather a php or web server problem. 
> 
> Is it possible that your php script prints to stderr instead of / in 
> addition to stdout? If exec detects output on stderr it will throw an 
> error unless stderr is redirected (this is all documented on the exec 
> man page) 
> 
> 
> > I even tried a variant: 
> > 
> > [TCL] 
> > set contentsList [exec $valPHPPath << '[regsub -all {'} $php {\\'} php; 
> > set php]'] 
> > [/TCL] 
> > 
> 
> Are you aware that single quotes are not a valid quoting mechanism for 
> Tcl? Any time you try to use single quotes to quote something in Tcl 
> you're bound to be disappointed. 
 
Yes, but I was assuming that I needed to encase $php in single quotes 
not for TCL exec but for the shell statement that is served by TCL 
exec, if that makes sense. 
 
Phil
 
  
Navigation:
[Reply to this message] 
 |