I am trying to execute tcl script inside php using passthru function. TCL script perfectly executes on the normal unix terminal. Whereas in php its not giving expected results on the browser.
I am passing the environment variable using passthru function in php. The environment variable is getting passed correctly but I am noticing the rest of the commands are not giving out the result. So I experimented trying to execute ls command and date command.
date
command gives the output on the browser whereas ls
doesn't give any output on the browser.
Why is this happening? It's the same result with who
and other commands with large output. Is there anything I am missing here??
Here is my sample tcl script ls_sample.tcl
puts "entering tcl"
set date_variable [exec date]
puts $date_variable
set ls_variable [exec ls]
puts $ls_variable
Sample output on the browser:
executing tclscript entering tcl Thu Oct 18 23:23:38 PDT 2012
why is ls
not printed? Whereas it works completely fine on the unix terminal?
I think it could be an Apache/Php/your system configuration problem. I just tried the same example under my machine and got the right result:
I also tried to reproduce the problem by doing these things, but it always worked for me:
ls /usr/bin
, for getting a longer stringwho
, for varietychown
ed the.tcl
file to a different user/group from the one used by Apache (www-data:www-data
)chown
ed the.tcl
file (as before), andchmod o-rx
the directorypassthru('tclsh pttest.tcl')
topassthru('./pttest.tcl')
, madepttest.tcl
executable and added#!/usr/bin/tclsh
as first linechown
ing thepttest.tcl
fileNone of these tests gave me your problem. I'm now adding the Apache configuration for the testing directory I used.
Sorry if I can't answer your question, but maybe these information can help you.