Gert Vanthienen's blog

Tuesday, May 27, 2008

Sending HTTP response code in ILE RPG

We (Tim Wyers and I) just spend a few hours to find out how to send an HTTP response code from an ILE RPG CGI program on System i. From the documentation provided by IBM, it looked like the QzhbCgiUtils API was the way to go, but we ended up with a this very simple solution: If you just write Status: 404 Not found to standard out, the HTTP server will translate that into the HTTP/1.1 404 Not found response code.

d WriteStdout pr ExtProc('QtmhWrStout')
d 65535a Const Options(*Varsize) //data variable
d 9b 0 Const //length of data
d 16a Options(*Varsize) //error struct
d/Copy Qsysinc/Qrpglesrc,Qusec
WriteStdout('Status: 404 Not Found' + X'15': 25: Qusec);
WriteStdout('Content-type: text/html'+X'15'+X'15': 27: Qusec);
WriteStdout('<html\><body>Page not found</body></html>': 29: Qusec);

Labels: ,

Friday, May 16, 2008

NTP on SuSE 9.3

I just spent a few hours trying to get an NTP server working on SuSE 9.3. Correction: I spent most of this time getting the SuSEfirewall2 to allow NTP traffic. Apparently, this can't be configured through YaST in SuSE 9.3 but you have to edit /etc/sysconfig/SuSEfirewall2 and add these two parameters:

# Obviously, you have to configure the external interface to allow NTP UDP datagrams
# ...but you also need this to get the NTP server working