$ENV{REMOTE_ADDR} or $ENV{HTTP_HOST} or $ENV{HTTP_USER_AGENT} [download]
In reply to How can a script know if it's a cgi? by DBX