samedi 18 avril 2015

CGI wont display variables through HTML in c (Eclipse)

I have used a fifo pipe to read in some data (weather data) into a char variable. The console will display this variable correctly. However, when I try to display it through HTML on the CGI page, it simply does not display. Code below -



int main(void) {
int fd;
char *myfifo = "pressure.txt";
char buff[BUFFER];
long fTemp;

//open and read message
fd = open(myfifo, O_RDONLY);
read(fd, buff, BUFFER);
printf("Received: %s\n", buff);
close(fd);



printf("Content-type: text/html\n\n");
puts("<HTML>");
puts("<BODY>");
printf("Data is: %s", buff);
puts("</BODY>");
puts("</HTML>");

return EXIT_SUCCESS;
}


As you can see in the console is displays correctly -



Received: 2014-08-13 16:54:57
25.0 DegC, 1018.7 mBar

Content-type: text/html

<HTML>
<BODY>
Data is 2014-08-13 16:54:57
25.0 DegC, 1018.7 mBar
</BODY>
</HTML>
logout


But on the CGI webpage it does not display the weather data, but it does display "data is".


Aucun commentaire:

Enregistrer un commentaire