Re: FQDN of the server thru CLI
| From: | Hans Juergen von Lengerke | Date: | Tue, 04 Apr 2006 13:08:28 +0000 |
| Subject: | Re: FQDN of the server thru CLI | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233195@lists.php.net to get a copy of this message | ||
I usually do this by forcing the profile to be read before I
run the script. Something like
* * * * * . /etc/profile && /path/to/script
> Date: Tue, 04 Apr 2006 17:43:09 +0530
> From: Venkat Venkataraju <outofjungle@gmail.com>
> To: php-general@lists.php.net
> Subject: [PHP] FQDN of the server thru CLI
>
> Hi All
>
> I'm writing a bunch of cron scripts that send reports periodically using
> phpmailer.
>
> I'm having a hard time trying to find the FQDN of the server. I need
> that information to construct the from address for the emails.
>
> The $_ENV['HOSTNAME'] works only if the script is executed manually. the
> cron does not pass the HOSTNAME env variable to the scripts.
>
> When executed from the CLI, the $_SERVER['HOSTNAME'] does not have the
> fqdn, but just the hostname part of the FQDN.
>
> Unless i hard code the corntab file with
> HOSTNAME=fqdn
>
> i do not want to hardcode the hostname anywhere as these script will be
> copied onto many servers. is there a way i can find the fully qualified
> domain name thru PHP?
>
> Thanks
> /V
>
>