Forum Moderators: coopster

Message Too Old, No Replies

get SERVER_NAME from commandline

         

ethan

11:44 am on Jul 10, 2004 (gmt 0)

10+ Year Member



Hi all,

I'm trying to determine the servername from a php script that is called either from standard web page or from a command line.

The problem is that from commandline the $_SERVER["SERVER_NAME"] variable is not set, neither with getenv("SERVER_NAME")...

So, do you have any ideas on how to determine the server name from the commandline execution of a php script?

Thanks all!

dmorison

12:03 pm on Jul 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're on a *nix box, the following should work:

$myhostname=exec("hostname");

Remember that when executing as a web page, $_SERVER["SERVER_NAME"] may contain a virtual host name, which may not be the same as the name returned by the system command "hostname".

ethan

12:33 pm on Jul 10, 2004 (gmt 0)

10+ Year Member



Thanks that's an approach :)