tags:

views:

176

answers:

1

Hello,

I have a PHP script that executes a TCL script . The TCL script creates a file , but when I execute through PHP (from browser) , tcl is not able to create a file.

Can anyone guide me .

//PHP code

<?php

$app = 'tclsh84';
$descriptorspec = array(
0 => array("pipe","r"),
1 => array("file","C:/wamp/www/tcl/bin/out.txt","w"),
2 => array("file","C:/wamp/www/tcl/bin/error.txt","w")
) ;
$process = proc_open($app, $descriptorspec, $pipes);
if (is_resource($process)) 
{
 fwrite($pipes[0], 'source c:/wamp/www/tcl/bin/show.tcl'."\n");
 fwrite($pipes[0], ' status 124 mithun '."\n");
fclose($pipes[0]);
proc_close($process);
}
?>

//TCL code

proc status {id uname} {
set x 1
set outfile [open "report.txt" w]
while {$x < 30} {
set systemTime [clock seconds]
puts $outfile "The time is: [clock format $systemTime -format %H:%M:%S] "
 puts $outfile "$id $uname "
 set x [expr {$x + 1}]
 }
 close $outfile 
 }

Thef file report.txt is not created .

+2  A: 

Looking at your TCL code it is trying to create a file called report.txt but you don't specify where in the directory structure is that it is being created. So I think that it will be trying to create the file in whichever directory you web server has set as it home directory.

Change the file name in the TCL script to put the file somewhere you know it can be written and see if this solves your problem.

Jackson