Posted by Bryan Oakley on 11/25/06 15:54
comp.lang.tcl wrote:
> set cannotRunPHP [catch {exec "echo '$php' | php" >@stdout
> 2>&stderr} errorMsg]
You need to re-read the man page on exec. The first argument to exec is
a filename that will be exec'd; it is not a command line. If you want to
run a command line you should exec a command line processor (/bin/sh,
command.com, whatever).
Since "php" is what you want to exec, and $php is what you want to send
to its stdin, use "<<" (documented on the exec man page):
if {[catch {exec php << $php} result]} {
puts "error exec'ing php: $resulut"
} else {
puts "php result: $result"
}
You can read a wiki page on the subject here: http://mini.net/tcl/exec
[Back to original message]
|