Error 500: Premature end of script headers

It was a file permission issue. All files on my website were set to a permission level of ‘644.’ Once I changed the permission level to 705 (chmod 705) everything worked. Note that I changed it to 705, but 755 will also work. I also changed the folder it was in to 701 (to hide … Read more

Call PHP from virtual/custom “web server”

Invoking a CGI script is pretty simple. PHP has a few peculiarities, but you basically only need to setup a list of environment variables, then call the PHP-CGI binary: setenv GATEWAY_INTERFACE=”CGI/1.1″ setenv SCRIPT_FILENAME=/path/to/script.php setenv QUERY_STRING=”id=123&name=title&parm=333″ setenv REQUEST_METHOD=”GET” … exec /usr/bin/php-cgi Most of them are boilerplate. SCRIPT_FILENAME is how you pass the actual php filename to … Read more

Posting html form values to python script

in the form action form action=””, put the location of your cgi script and the value of the textbox will be passed to the cgi script. eg. <form name=”search” action=”/cgi-bin/test.py” method=”get”> Search: <input type=”text” name=”searchbox”> <input type=”submit” value=”Submit”> </form> in your test.py import cgi form = cgi.FieldStorage() searchterm = form.getvalue(‘searchbox’) thus you will get the … Read more

How to parse $QUERY_STRING from a bash CGI script?

Try this: saveIFS=$IFS IFS=’=&’ parm=($QUERY_STRING) IFS=$saveIFS Now you have this: parm[0]=a parm[1]=123 parm[2]=b parm[3]=456 parm[4]=c parm[5]=ok In Bash 4, which has associative arrays, you can do this (using the array created above): declare -A array for ((i=0; i<${#parm[@]}; i+=2)) do array[${parm[i]}]=${parm[i+1]} done which will give you this: array[a]=123 array[b]=456 array[c]=ok Edit: To use indirection in … Read more

Differences and uses between WSGI, CGI, FastCGI, and mod_python in regards to Python?

A part answer to your question, including scgi. What’s the difference between scgi and wsgi? Is there a speed difference between WSGI and FCGI? How Python web frameworks, WSGI and CGI fit together CGI vs FCGI Lazy and not writing it on my own. From the wikipedia: http://en.wikipedia.org/wiki/FastCGI Instead of creating a new process for … Read more

How to get rid of non-ascii characters in ruby

Use String#encode The official way to convert between string encodings as of Ruby 1.9 is to use String#encode. To simply remove non-ASCII characters, you could do this: some_ascii = “abc” some_unicode = “áëëçüñżλφθΩ𠜎😸” more_ascii = “123ABC” invalid_byte = “\255” non_ascii_string = [some_ascii, some_unicode, more_ascii, invalid_byte].join # See String#encode documentation encoding_options = { :invalid => :replace, … Read more