ID: 38341 User updated by: manikandan dot r at greynium dot com Reported By: manikandan dot r at greynium dot com Status: Bogus Bug Type: Output Control PHP Version: 5.1.4 New Comment:
Thanks John.. But I got the $_SERVER variable values in CLI itself. Array structure got from the CLI : ------------------------------------------------- ["_SERVER"]=> array(39) { ["USER"]=> string(7) "mytoday" ["LOGNAME"]=> string(7) "mytoday" ["HOME"]=> string(51) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com" ["PATH"]=> string(244) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com/bin:/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com/checkmail:/usr/bin:/usr/sbin:/usr/local/bin:/bin:/usr/bin:/usr/ucb:usr/etc:/usr/etc:/usr/local/mysql/bin:/disk2/download/tidy-1.2/tidy:." ["MAIL"]=> string(23) "/var/spool/mail/mytoday" ["SHELL"]=> string(9) "/bin/tcsh" ["SSH_CLIENT"]=> string(28) "::ffff:192.168.2.104 3743 22" ["SSH_CONNECTION"]=> string(48) "::ffff:192.168.2.104 3743 ::ffff:192.168.1.18 22" ["SSH_TTY"]=> string(11) "/dev/pts/10" ["TERM"]=> string(5) "vt100" ["HOSTTYPE"]=> string(10) "i386-linux" ["VENDOR"]=> string(5) "intel" ["OSTYPE"]=> string(5) "linux" ["MACHTYPE"]=> string(4) "i386" ["SHLVL"]=> string(1) "1" ["PWD"]=> string(72) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com/public_html/greynium" ["GROUP"]=> string(7) "mytoday" ["HOST"]=> string(17) "php5.greynium.com" ["REMOTEHOST"]=> string(13) "192.168.2.104" ["LS_COLORS"]=> string(440) "no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:" ["G_BROKEN_FILENAMES"]=> string(1) "1" ["SSH_ASKPASS"]=> string(38) "/usr/libexec/openssh/gnome-ssh-askpass" ["KDEDIR"]=> string(4) "/usr" ["LANG"]=> string(1) "C" ["SUPPORTED"]=> string(20) "en_US.UTF-8:en_US:en" ["LESSOPEN"]=> string(24) "|/usr/bin/lesspipe.sh %s" ["QTDIR"]=> string(15) "/usr/lib/qt-3.3" ["HOSTNAME"]=> string(17) "php5.greynium.com" ["INPUTRC"]=> string(12) "/etc/inputrc" ["CVSROOT"]=> string(55) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com/CVS" ["errorlog"]=> string(51) "/disk2/v/apache/logs/mytoday.greynium.com-error.log" ["PHP_SELF"]=> string(12) "hosttest.php" ["SCRIPT_NAME"]=> string(12) "hosttest.php" ["SCRIPT_FILENAME"]=> string(12) "hosttest.php" ["PATH_TRANSLATED"]=> string(12) "hosttest.php" ["DOCUMENT_ROOT"]=> string(0) "" ["REQUEST_TIME"]=> int(1154779834) ["argv"]=> array(1) { [0]=> string(12) "hosttest.php" } ["argc"]=> int(1) } Array structure from same php file when it is run as cronjob: ----------------------------------------------------- ["_SERVER"]=> array(16) { ["SHELL"]=> string(7) "/bin/sh" ["USER"]=> string(7) "mytoday" ["PATH"]=> string(13) "/usr/bin:/bin" ["PWD"]=> string(51) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com" ["SHLVL"]=> string(1) "1" ["HOME"]=> string(51) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com" ["LOGNAME"]=> string(7) "mytoday" ["_"]=> string(12) "/usr/bin/php" ["PHP_SELF"]=> string(85) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com/public_html/greynium/hosttest.php" ["SCRIPT_NAME"]=> string(85) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com/public_html/greynium/hosttest.php" ["SCRIPT_FILENAME"]=> string(85) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com/public_html/greynium/hosttest.php" ["PATH_TRANSLATED"]=> string(85) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com/public_html/greynium/hosttest.php" ["DOCUMENT_ROOT"]=> string(0) "" ["REQUEST_TIME"]=> int(1154779741) ["argv"]=> array(1) { [0]=> string(85) "/disk2/v/apache/htdocs/VIRTUAL/mytoday.greynium.com/public_html/greynium/hosttest.php" } ["argc"]=> int(1) } So can you check the above two array structures and give me some ideas to get the hostname? Moreover i checked the Environment variable also, hostname is not available there. ---- Mani Previous Comments: ------------------------------------------------------------------------ [2006-08-05 11:49:40] [EMAIL PROTECTED] HOST variables comes from the web server, so it doesn't exist with CLI. There is also HOSTNAME environment variable, which is usually set on *nix systems. ------------------------------------------------------------------------ [2006-08-05 09:15:07] manikandan dot r at greynium dot com Description: ------------ I used $_SERVER global variable to get the hostname and it is working fine, when the programs run in command line. But i was not get the value of the hostname [ $_SERVER['HOST']] when the file runs as cronjob. How to get the value of hostname? ---- Mani Reproduce code: --------------- echo $_SERVER['HOST']; Expected result: ---------------- php5.greynium.com -My development server hostname. Actual result: -------------- Empty ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38341&edit=1