473,883 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'echo "": No such file or directory" error using "exec" to pipe in PHP script

[TCL]

set php {<? print_r("Hello World"); ?>}
puts $php; # PRINTS OUT <? print_r("Hello World"); ?>
puts [exec "echo '$php' | php -q"]

[/TCL]

When I try this within TCL I get the following error:

echo "": No such file or directory
I am unable to be able to use the CLI PHP "php -r" option due to my PHP
installations on various servers being CGI and not CLI SAPI, else, I
would just do that, so I'm trying an alternative that is choking TCL.

I am using a very simple example within the TCL $php variable; the
actual contents of $php will be a bit more complex and dynamic,
however, it's still choking on the simple PHP content.

So how on earth do I get TCL and PHP to play nice?

Thanx
Phil

Dec 1 '06
21 7881
comp.lang.tcl wrote:
This is the error I 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 -q << $php" (procedure "XML_GET_ALL_EL EMENT_ATTRS" line 37)
this may be an error or just happen because the invokation of php outputs
something to stderr.
you may want to wrap the [exec ... ] into a catch statement like:

if {[catch {exec $valPHPPath -q << $php"} retval]} {
# talk about what the error was
puts stderr "exec with error: $retval"
} else {
# do something sensible with a successfull return.
}
and see whats happening.
catch is very usefull, but you may want to take some rye on the side ;-)

uwe
Dec 1 '06 #11

Uwe Klein wrote:
comp.lang.tcl wrote:
This is the error I 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 -q << $php" (procedure "XML_GET_ALL_EL EMENT_ATTRS" line 37)

this may be an error or just happen because the invokation of php outputs
something to stderr.
you may want to wrap the [exec ... ] into a catch statement like:

if {[catch {exec $valPHPPath -q << $php"} retval]} {
# talk about what the error was
puts stderr "exec with error: $retval"
} else {
# do something sensible with a successfull return.
}
and see whats happening.
catch is very usefull, but you may want to take some rye on the side ;-)

uwe
I wish I could see what's happening, but I have no way of ever knowing
what's going on

if {[catch [exec $valPHPPath -q << $php] errMsg]} {
puts "!!error in exec: $errMsg!!"
} else {
puts "This is your list!"
return "This is your list: $errMsg"
}

produces:

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 -q << $php" (procedure "XML_GET_ALL_EL EMENT_ATTRS" line 37)

It is not even performing "puts" in either case, so I am not apparently
even catching the error, or I have no idea what's going on!

Phil

Dec 1 '06 #12
comp.lang.tcl wrote:
Bryan Oakley wrote:
>>Show us *precisely* what you type.


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_cre ate();
@xml_parse_into _struct($parser , $xml, $xmlArray, $tags);
@xml_parser_fre e_parser($parse r);
for ($i = 1; $i < @sizeof($xmlArr ay) - 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);
?>}

global valPHPPath
if {![info exists valPHPPath]} {
if {![array exists env]} { global env }
source cgi_globals.tcl
global valPHPPath
}
set contentsList [exec $valPHPPath << $php]
-----------
There you go, exactly what I typed
-----------

This is the error I 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 -q << $php" (procedure "XML_GET_ALL_EL EMENT_ATTRS" line 37)
Strip out all the Tcl. All of it. Every last byte. Put the php into a
file. Then, from a command line type "php /your/file.php"

You will get the exact same error. The bug is in php, of which I know
nothing about. What I do know is that the problem isn't Tcl.
Dec 1 '06 #13

Bryan Oakley wrote:
comp.lang.tcl wrote:
Bryan Oakley wrote:
>Show us *precisely* what you type.

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_cre ate();
@xml_parse_into _struct($parser , $xml, $xmlArray, $tags);
@xml_parser_fre e_parser($parse r);
for ($i = 1; $i < @sizeof($xmlArr ay) - 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);
?>}

global valPHPPath
if {![info exists valPHPPath]} {
if {![array exists env]} { global env }
source cgi_globals.tcl
global valPHPPath
}
set contentsList [exec $valPHPPath << $php]
-----------
There you go, exactly what I typed
-----------

This is the error I 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 -q << $php" (procedure "XML_GET_ALL_EL EMENT_ATTRS" line 37)

Strip out all the Tcl. All of it. Every last byte. Put the php into a
file. Then, from a command line type "php /your/file.php"

You will get the exact same error. The bug is in php, of which I know
nothing about. What I do know is that the problem isn't Tcl.
No, sorry I get no error whatsoever, in fact, I get nothing. It's not
a PHP syntax or evaluation error, it's just that apparently it seems
$argv does not exist because it was never set with any values, so
putting it into a PHP file is ultimately meaningless because I can't
get the XML contents into the PHP file even if it were separate.

So again, at this point, you're right, this is not a TCL issue and
needs to be moved to a PHP issue.

Phil

Dec 1 '06 #14
comp.lang.tcl wrote:
Bryan Oakley wrote:
>>comp.lang.t cl wrote:
>>>Bryan Oakley wrote:

Show us *precisely* what you type.
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_cre ate();
@xml_parse_into _struct($parser , $xml, $xmlArray, $tags);
@xml_parser_fre e_parser($parse r);
for ($i = 1; $i < @sizeof($xmlArr ay) - 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);
?>}

global valPHPPath
if {![info exists valPHPPath]} {
if {![array exists env]} { global env }
source cgi_globals.tcl
global valPHPPath
}
set contentsList [exec $valPHPPath << $php]
-----------
There you go, exactly what I typed
-----------

This is the error I 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
$valPHPPat h -q << $php" (procedure "XML_GET_ALL_EL EMENT_ATTRS" line 37)

Strip out all the Tcl. All of it. Every last byte. Put the php into a
file. Then, from a command line type "php /your/file.php"

You will get the exact same error. The bug is in php, of which I know
nothing about. What I do know is that the problem isn't Tcl.


No, sorry I get no error whatsoever, in fact, I get nothing.
You are correct. My bad. I was getting this, which is the same error
you were earlier reporting:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/private/tmp/error.php on line 9

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/private/tmp/error.php on line 14

.... but that was because the php had two lines with extra backslashes,
that were in to escape the curly braces due to the fact it was defined
in Tcl. My mistake. When I took those out in the file-based version of
the php code, it all worked fine (and by that I mean, I get no php errors).
It's not
a PHP syntax or evaluation error, it's just that apparently it seems
$argv does not exist because it was never set with any values,
That's likely also true. Unless you give it a filename as an argument
you won't have a argv[1].
so
putting it into a PHP file is ultimately meaningless because I can't
get the XML contents into the PHP file even if it were separate.
The exercise of putting it in a file is just to illustrate that the php
has errors in it, it has nothing to do with Tcl. If you can create a
working block of php you can call from the command line, you can
certainly execute it from tcl using the "exec php << $php" trick.

The first trick, then, is to figure out the PHP problems. Then take the
working PHP and execute it via Tcl. No sense fighting two battles at once.
Dec 1 '06 #15

Bryan Oakley wrote:
comp.lang.tcl wrote:
Bryan Oakley wrote:
>comp.lang.tc l wrote:

Bryan Oakley wrote:

Show us *precisely* what you type.
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_cre ate();
@xml_parse_into _struct($parser , $xml, $xmlArray, $tags);
@xml_parser_fre e_parser($parse r);
for ($i = 1; $i < @sizeof($xmlArr ay) - 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);
?>}

global valPHPPath
if {![info exists valPHPPath]} {
if {![array exists env]} { global env }
source cgi_globals.tcl
global valPHPPath
}
set contentsList [exec $valPHPPath << $php]
-----------
There you go, exactly what I typed
-----------

This is the error I 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 -q << $php" (procedure "XML_GET_ALL_EL EMENT_ATTRS" line 37)

Strip out all the Tcl. All of it. Every last byte. Put the php into a
file. Then, from a command line type "php /your/file.php"

You will get the exact same error. The bug is in php, of which I know
nothing about. What I do know is that the problem isn't Tcl.

No, sorry I get no error whatsoever, in fact, I get nothing.

You are correct. My bad. I was getting this, which is the same error
you were earlier reporting:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/private/tmp/error.php on line 9

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/private/tmp/error.php on line 14

... but that was because the php had two lines with extra backslashes,
that were in to escape the curly braces due to the fact it was defined
in Tcl. My mistake. When I took those out in the file-based version of
the php code, it all worked fine (and by that I mean, I get no php errors).
It's not
a PHP syntax or evaluation error, it's just that apparently it seems
$argv does not exist because it was never set with any values,

That's likely also true. Unless you give it a filename as an argument
you won't have a argv[1].
Ok an update:

My TCL code has been simplified to this:

set contents {<?xml version="1.0" encoding="utf-8" ?><blah><foo
id="1"></foo></blah>}
if {[catch [exec $valPHPPath -q /home/ppowell/web/blah.php <<
$contents] errMsg]} {
puts "!!error in exec: $errMsg!!"
} else {
puts "This is your list!"
Where I put all of the contents of [set php] into "blah.php" and
calling that instead.

Well, to no avail:

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 -q /home/ppowell/web/blah.php << $contents" (procedure
"XML_GET_ALL_EL EMENT_ATTRS" line 39)

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]
>
so
putting it into a PHP file is ultimately meaningless because I can't
get the XML contents into the PHP file even if it were separate.

The exercise of putting it in a file is just to illustrate that the php
has errors in it, it has nothing to do with Tcl. If you can create a
working block of php you can call from the command line, you can
certainly execute it from tcl using the "exec php << $php" trick.
working PHP and execute it via Tcl. No sense fighting two battles at once.
Dec 1 '06 #16
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
Dec 1 '06 #17

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('f unctions.inc.ph p');
$xml = preg_replace('/(>)[\n\r\\s\t]+(<)/', '$1$2',
@file_get_conte nts('php://stdin'));
$parser = @xml_parser_cre ate();
@xml_parse_into _struct($parser , $xml, $xmlArray, $tags);
@xml_parser_fre e($parser);
for ($i = 1; $i < @sizeof($xmlArr ay) - 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

Dec 2 '06 #18
"comp.lang. tcl" <ph************ **@gmail.comwro te:
Uwe Klein wrote:
you may want to wrap the [exec ... ] into a catch statement like:

if {[catch {exec $valPHPPath -q << $php"} retval]} {
...

and see whats happening.
catch is very usefull, but you may want to take some rye on the side ;-)

uwe

I wish I could see what's happening, but I have no way of ever knowing
what's going on

if {[catch [exec $valPHPPath -q << $php] errMsg]} {
...
Look closely at the difference between what Uwe suggested and what you
actually did. The [catch] command expects a script; you instead gave it
the results of executing the [exec] command.
Dec 2 '06 #19

Alan Anderson wrote:
"comp.lang. tcl" <ph************ **@gmail.comwro te:
Uwe Klein wrote:
you may want to wrap the [exec ... ] into a catch statement like:
>
if {[catch {exec $valPHPPath -q << $php"} retval]} {
...
>
and see whats happening.
catch is very usefull, but you may want to take some rye on the side ;-)
>
uwe
I wish I could see what's happening, but I have no way of ever knowing
what's going on

if {[catch [exec $valPHPPath -q << $php] errMsg]} {
...

Look closely at the difference between what Uwe suggested and what you
actually did. The [catch] command expects a script; you instead gave it
the results of executing the [exec] command.
I got to the point where the PHP script that the Tcl script is calling
is somewhat stable (provided you have very tiny inputted data!), I
guess I just won't understand how to look at what Uwe did and what I
did and see the difference as your explanation doesn't make sense
either, sorry.

Phil

Dec 2 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4342
by: Thomas Brathans | last post by:
Hi, when I try to execute the obove mentioned to synchronise the servertime by a php-script, it doesn't work. Other shell-commands work fine. Executing ntpdate <server> directly in the shell works also well. So why doesn't it work? Thanks...
5
5786
by: Toby Donaldson | last post by:
Hi all, I'm designing an educational application that will run Python code and check the output against a pre-define answer. I want to use the "exec" statement to run the code, but I don't know how to get output from it. For instance, exec works like this: >>> code = """ for i in xrange(1, 5):
2
4193
by: tedsuzman | last post by:
----- def f(): ret = 2 exec "ret += 10" return ret print f() ----- The above prints '12', as expected. However,
1
1699
by: Ted | last post by:
-------- def f(): ret = 2 exec "ret += 10" return ret print f() -------- The above example prints '12'. However, the following example prints
1
2689
by: kurt.krueckeberg | last post by:
The second line of this script <?php // current directory echo getcwd() . "<br />"; print ( exec("ls *.*") ); ?> should display the names of the four files (it does in an ssh session) which are located in public_html, but instead it displays just one filename, that of this script.
2
10357
by: Marty Meyers | last post by:
I have the following line in a php file: $msg= exec("perl $scriptPath/insert.pl $d $u $t 2>&1", $returnVal); Can someone explain the "2>&1" argument? Second problem, this same line of code when run from the unix command line returns the following error:
4
12620
by: Tom | last post by:
I have a script which allows a user to upload a file. The script does some filename editing, mimetype checking, etc., and it's then supposed to send the file to a remote server, without any username/password prompt ( I have root access to both servers ). I'm trying to run an exec/passthru command using scp or rsync, but there's one fundamental question that I can't answer. When exec is called from the command line, e.g. `php...
2
3118
by: xml0x1a | last post by:
How do I use exec? Python 2.4.3 ---- from math import * G = 1 def d(): L = 1 exec "def f(x): return L + log(G) " in globals(), locals() f(1)
2
2444
by: shathil | last post by:
#!/bin/bash cat /var/backup/192.168.4.3/dirnum.prn | awk '{print $1}' if i put above script can read the file. #!/bin/bash file1=/var/backup/192.168.4.3/dirnum.prn exec <$file1 while read line
0
9945
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10863
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10422
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9588
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6007
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4622
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3241
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.