|
Posted by comp.lang.tcl on 11/25/06 18:11
Bryan Oakley wrote:
> 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"
> }
Now I get this error:
couldn't execute "php": no such file or directory
When I try this:
[TCL]
set cannotRunPHP [catch {exec exec php << $php >@stdout 2>&stderr}
errorMsg]
if {$cannotRunPHP} {
puts $errorMsg
return {}
} else {
if {![IS_LIST $contentsList]} { set contentsList [split
$contentsList] }
if {[llength $contentsList] == 0} { lappend contentsList {?} }
return [lrange $contentsList [expr {[lsearch -exact $contentsList
"?"] + 1}] end]
}
[/TCL]
Wow this should only take an hour, it's taken 3 days so far!
Phil
>
> You can read a wiki page on the subject here: http://mini.net/tcl/exec
Navigation:
[Reply to this message]
|