problem executing command
Posted: Tue Jul 20, 2010 1:26 pm
I am trying to connect remotely to a machine an run a little script. Then get the output in php.
The script runs find in the command line. Now when I try running it using php, I get the following error
[text]
Array
(
[stdout] =>
[stderr] => 'c:/Windows/System32/plink.exe' is not recognized as an internal or external command,
operable program or batch file.
[return] => 1
)
[/text]
I am using a little script that I found on php.net
The plink is in windows\system32 so any program should be able to find it, right? In any case I gave it the whole path and still have the same problem.
My script
Thank you for any help
The script runs find in the command line. Now when I try running it using php, I get the following error
[text]
Array
(
[stdout] =>
[stderr] => 'c:/Windows/System32/plink.exe' is not recognized as an internal or external command,
operable program or batch file.
[return] => 1
)
[/text]
I am using a little script that I found on php.net
Code: Select all
function my_exec($cmd, $input='')
{$proc=proc_open($cmd, array(0=>array('pipe', 'r'), 1=>array('pipe', 'w'), 2=>array('pipe', 'w')), $pipes);
fwrite($pipes[0], $input);fclose($pipes[0]);
$stdout=stream_get_contents($pipes[1]);fclose($pipes[1]);
$stderr=stream_get_contents($pipes[2]);fclose($pipes[2]);
$rtn=proc_close($proc);
return array('stdout'=>$stdout,
'stderr'=>$stderr,
'return'=>$rtn
);
}
My script
Code: Select all
$cmd ="c:/Windows/System32/plink.exe -ssh -pw password user@host \"/path/findlog.sh {$phone}\"";
echo $cmd;
var_dump(my_exec($cmd));