How to capture serial data and show it in a php webpage?

Hi all!

I have my Arduino as a batery charger and batery monitor.
This send via RS-232 a string similar to this:

13.8|0.22|12.5|CRC|CR&LF

I'm using a linux server with an Apache web server.
Now I know that I must use BASH or PERL to write an script to capture this data at the serial port and parse it.

Now what is the best way to do this? capture the string into a text file using a BASH script and then read the file from the PHP page and print it in the webpage?

Best Regards!
Frank

Now I know that I must use BASH or PERL to write an script to capture this data at the serial port and parse it.

Those are only two possibilities. There are dozens of others.

Now what is the best way to do this? capture the string into a text file using a BASH script and then read the file from the PHP page and print it in the webpage?

Neither of those languages would be my choice. PHP can read directly from the serial port, and skip all that crap with having the script open a file, write to it, close it, and then having PHP open it, read it, and close it.

If the monitoring is web based you can use Perl with module device:SerialPort or PHP with php_serial_class; there are other options to write what you need but using Perl or Php you can find many examples on web.
All "todo" is to read the data from serial port, split(Perl)/(explode Php) it using the pipe (|) char and print the resulting array rows (quite similar in both languages).
You might also use bash or Perl to write a simple text console monitor; in this case you don't need Apache

May be this will be helpfully to decide the software structure.
This battery system is inside my Atom & Linux SIP server. What I need to do when the battery system will be empty is send a cmd to the computer to shutdown itself. So for this case I think that PHP is no the option because we must have a user session on it.

So I need to execute the shutdown cmd and save in some file the battery controller string.

I think that the option will be BASH for the main and PHP for html printing

I'm correct?

Best Regards
Frank