473,883 Members | 1,682 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


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


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?


Dec 1 '06
21 7879
I've broken this post into small, bite-sized sections. I hope that
helps compensate for how long it is.

"comp.lang. tcl" <ph************ **@gmail.comwro te:
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.
Uwe Klein's suggestion:
if {[catch {exec $valPHPPath -q << $php} retval]} {...}
Phillip Powell's version:
if {[catch [exec $valPHPPath -q << $php] errMsg]} {...}
Do you see the difference between these two lines? Not the obvious
retval vs. errMsg names, but the {} vs. [] characters surrounding the
exec command.

*** ***

You're coming very close to fumbling blindly around in frustration,
trying to find exactly the combination of chicken entrails and mouth
position that will yield the results you want. If you instead take a
step back and spend just a little time getting a handle on the simple
syntax of Tcl, I think you'll find the time spent will pay off manyfold.

Look at this web page: http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm

It's only eleven rules. (The imminent twelfth rule is simple, but not
important at the moment.)

*** ***

Once you grasp what those " and { and $ and [ characters are actually
doing, you'll be freer to take a look at the commands you're using, and
find out what arguments they expect to receive.

For example, [exec]: http://www.tcl.tk/man/tcl/exec.htm

It wants to see a list of words. The first word in that list is the
command to be executed (sometimes preceded by an optional switch); the
rest of the words are passed to that command as parameters, with some
exceptional cases like "|" and "<<" treated, err, exceptionally.

Another example, [catch]: http://www.tcl.tk/man/tcl/catch.htm

It wants to see a pair of words. The first one is a script which it
evaluates; the second is the name of a variable in which to store the
results of evaluating the script.

*** ***

And use the Tcler's Wiki: http://wiki.tcl.tk/

It has pages giving simple and clear examples of just about any command
you want to use. In most cases, it also gives good advice on *why* you
should follow those examples.
Dec 2 '06 #21
In article <11************ *********@j44g2 000cwa.googlegr oups.com>,
comp.lang.tcl <ph************ **@gmail.comwro te:
Dec 2 '06 #22

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

Similar topics

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...
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):
by: tedsuzman | last post by:
----- def f(): ret = 2 exec "ret += 10" return ret print f() ----- The above prints '12', as expected. However,
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
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.
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:
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...
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)
by: shathil | last post by:
#!/bin/bash cat /var/backup/ | awk '{print $1}' if i put above script can read the file. #!/bin/bash file1=/var/backup/ exec <$file1 while read line
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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,...
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...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.