Title: Simple CGI Question? Post by: semyazza on August 18, 2010, 07:25:26 PM Hello,
I'm having a little trouble parsing and displaying the output from the bitcoind client in the browser from a CGI program written in C. Code:
Is producing only the following HTML code through the cgi interface: Code:
The command line output when run in a terminal is(which is correct): Code: <html> Any ideas? I know I'm missing something simple. Title: Re: Simple CGI Question? Post by: jgarzik on August 18, 2010, 07:35:50 PM FILE* output = popen("/var/www/bitcoind.cgi getblockcount", "r"); Seems like an incorrect execution string. Title: Re: Simple CGI Question? Post by: BioMike on August 18, 2010, 09:04:36 PM right permissions?
Title: Re: Simple CGI Question? Post by: semyazza on August 19, 2010, 02:21:08 PM FILE* output = popen("/var/www/bitcoind.cgi getblockcount", "r"); Seems like an incorrect execution string. Title: Re: Simple CGI Question? Post by: semyazza on August 19, 2010, 02:22:18 PM right permissions? Permissions are correct. Owner and group are the webserver and for testing purposes it is 777. Title: Re: Simple CGI Question? Post by: silverman on August 19, 2010, 03:56:59 PM Content-type: text/html\r\n ?
(or maybe it's Content-type: text/html\r\n\r\n, it's really fussy, and I forget.) Title: Re: Simple CGI Question? Post by: semyazza on August 19, 2010, 09:49:19 PM Content-type: text/html\r\n ? The recommendation is a double line break of \n\n.(or maybe it's Content-type: text/html\r\n\r\n, it's really fussy, and I forget.) http://www.w3.org/International/O-HTTP-charset I still can't figure this out :-(... anyone? It should be really simple. I even tried piping the output to a text file and it will not output correctly when run through CGI. I'm using Apache 2.2 if that helps anyone. Title: Re: Simple CGI Question? Post by: BioMike on August 20, 2010, 05:12:26 AM Do the server logs say anything useful?
Title: Re: Simple CGI Question? Post by: lfm on August 20, 2010, 08:44:44 AM right permissions? Permissions are correct. Owner and group are the webserver and for testing purposes it is 777. check the return values from the open. is it NULL? Title: Re: Simple CGI Question? Post by: semyazza on August 20, 2010, 02:04:58 PM Do the server logs say anything useful? I failed debugging 101 somewhere. The error log did indeed give me useful information.What happened: The bitcoind client when run acts as an RPC client and connects to the already running instance of bitcoind to get its data(I did not know that). Also, the default apache configuration uses / as its home directory not the same directory the bitcoind client uses to store the bitcoin.conf file. When bitcoind was run with a command switch from the CGI it was looking in the home directory of the user it was run from(the webserver) for bitcoin.conf and not from the home directory of the user bitcoind was running as. Fixes: 1) Have bitcoind and the webserver run as the same user so they share the same configuration directory 2) Create a link between the bitcoin.conf from the home directories of the users(webserver and bitcoind user) 3) Create a duplicate configuration file for both users. Thanks for the help everyone! Title: Re: Simple CGI Question? Post by: xcikni on August 23, 2010, 03:07:05 AM Have you tried closing the <head> tag?
Title: Re: Simple CGI Question? Post by: BioMike on August 23, 2010, 05:08:43 AM Have you tried closing the <head> tag? FYI. The problem was already solved. |