0

What actually i want to do is to get contents from the winword file in my web page. for this purpose i used the exec() method, i also tried the following code:

$pCom = new COM("WScript.Shell");
$pShell = $pCom->exec("Notepad.exe");
$sStdOut = $pShell->StdOut->ReadAll;    # Standard output
$sStdErr = $pShell->StdErr->ReadAll;    # Error
echo($sStdOut);

the above code through an Exception that:

 Fatal error: Class 'COM' not found in D:\xampp\htdocs\test\tests\Notepad.php on line 9

I have no idea what to do and how to do this?

Abdul Rahman
  • 1,669
  • 4
  • 24
  • 39
  • 1
    see: http://stackoverflow.com/questions/9299809/php-exec-not-returning and http://stackoverflow.com/questions/9114574/php-exec-does-not-return-output – CodeLove Nov 07 '15 at 07:54

1 Answers1

1

You have two issues with your approach:

  1. a text editor does not output text written in it when closing the editor. So why would you expect to receive the text when firing the editor by means of an exec() call?

  2. you miss understood how the exec() command actually works, I assume you did not really read the documentation of the exec() function which clearly states that the return value of an executed command is the last line of its output. That is not what you want.

arkascha
  • 41,620
  • 7
  • 58
  • 90