-4

Can any one tell me How to get values from a batch file and display the output in PHP script? I have a simple batch file and simply want to display values in html/php format,

Thanks!

  • do you want to get the output of batch file then display in php – Rohan Khude Nov 11 '16 at 10:46
  • Have tried anything so far? Can you post your code? – Athafoud Nov 11 '16 at 10:48
  • Well. You need to describe where. If you have a WAMP, it's simple. Store the batch output in a file or directly into a SQL database. Read it out with PHP. – Matt Backslash Nov 11 '16 at 10:48
  • @RohanKhude I think he needs he output of a batch file to display it in php. Not sure though. – geisterfurz007 Nov 11 '16 at 11:00
  • Possible duplicate of [How to pass variable from php to bat file and read its result?](http://stackoverflow.com/questions/39701896/how-to-pass-variable-from-php-to-bat-file-and-read-its-result) – Rohan Khude Nov 11 '16 at 11:35
  • @Athafoud I'm replying one week later! This is the thing I needed to do and i'm posting my piece of code here now.. I have a batch file (test.bat) and it contains few text. I want my php script to get values from test.bat file and dispaly in html/php page. Here's the code, Can someone tell me how to retrieve these values from the batch file and display in html/php? Thanks. – Purna Gunasekara Nov 18 '16 at 13:02
  • pls add your code as an edit / update to the question – Athafoud Nov 18 '16 at 13:17

1 Answers1

0

If you need the output from the .bat file to display in PHP, you can either run the file from PHP (not recommended) - this will only work on a computer running some version of DOS/Windows, so also not recommended, or you can run the file via the built-in scheduler in your operating system, outputting the values to a text-file or similar, and then read that file via PHP (a much safer option).

Although I'm guessing you're trying to do something you shouldn't be doing, so a bit more information might be needed.

junkfoodjunkie
  • 3,168
  • 1
  • 19
  • 33