MATLAB: How to send data from CGI to the MATLAB compiled application via STDIN

Parallel Computing Toolbox

I would like to use the CGI POST commands to send data to STDOUT so that it may be read by my MATLAB application from STDIN.
I tried to use the FREAD command as follows:
i = fread(0);
but I receive the following error message:
??? Error using ==> fread
Operation is not implemented for requested file identifier.

Best Answer

It is not possible for MATLAB to read from STDIN when using the CGI command POST.
There are two workarounds:
1) Use the CGI command GET to set an environment variable that is then read in in the MATLAB compiled application.
2) Have CGI write to STDOUT. Compile the MATLAB code to a shared library. Create a driver C program that calls the shared library. This driver program will also read from STDIN.
3) Use CGI to write to a file on disk. Then read from the file inside the MATLAB compiled application.