finding stuff on a hosted server

Migrated. Originally posted: 2008-02-17

I wanted to find out if a particular bit of software was installed on the server where one of my sites is hosted. Let’s call that software “django” and “ruby on rails”.

Here is a version of the script. Note the “exec” line to put the error messages into standard output instead of the Apache error log. The first two echo lines are the HTTP message telling your browser that the output should be displayed as an HTML page. Yes, the second echo isn’t echoing anything. That creates a required blank line in the output after the “Content-type” is defined.

#!/bin/bash
echo Content-type: text/html
echo

# map stderr to stdout
exec 2>&1

echo '<h1>Computer info</h1>'
echo '<p>'
uname -a

echo '<h2>Finding stuff</h2>'
echo '<p>'
which perl
echo '<p>'
which ruby
echo '<p>'
which python

echo '<p>'
echo PATH:
echo $PATH

echo '<h2>Python</h2>'
echo '<p>'
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
echo '<p>'
which django-admin.py
echo '<p>'
locate django-admin.py

And here is some options I had to add to my “.htaccess” file so that Apache would allow me to run a shell script.

# Set some options.
Options -Indexes
Options +FollowSymLinks
Options +ExecCGI
AddHandler cgi-script cgi pl sh rb py

And here is an option in the top level directory. I had to remove “sh” from this list. This “.htaccess” file was provided by Drupal.

# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|install|module|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root)$">
  Order deny,allow
  Deny from all
</FilesMatch>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s