0

I have installed html-to-text through Node.js . When I run the following command in the shell:

C:\> html-to-text < D:\test.html --tables=true --wordwrap=false > D:\test.txt

the file D:\\test.html is properly converted to txt and I find the proper output next to it in D:\\ folder. However, if I try to run exactly the same command through PHP on my local server:

<?php
exec('html-to-text < D:\\test.html --tables=true --wordwrap=false > D:\\test.txt');
?>

The script runs and produces a .txt file, but the .txt file is empty.

What causes this different behavior? How should I run the script through PHP and get the proper result instead of empty file? Thanks for any suggestion!

Kagaratsch
  • 963
  • 8
  • 18
  • 1
    You could try to run a batch script containing that line - there are some other questions about this topic that mention that the redirection does not work properly using `exec` – Nico Haase Feb 19 '19 at 16:13
  • Perhaps drive `D:` doesn't exist in the context the code runs in; have you already tried a UNC alternative? – aschipfl Feb 19 '19 at 16:28
  • @NicoHaase I put the command in a bat file and called the file from PHP. Unfortunately, it gave the same result... empty output txt. – Kagaratsch Feb 19 '19 at 16:36
  • @aschipfl The script actually runs and puts a txt file into `D:`, but somehow it is empty instead of containing the output. Which seems to mean that `D:` is accessible from context... – Kagaratsch Feb 19 '19 at 16:37

0 Answers0