Home > Archive > PHP Language > August 2005 > getting username
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Kleist 2005-08-30, 3:55 am |
| Hello,
I know that it rother not strict PHP question, but
nevertheless, I'd like to know how to get username of the
user who has run CLI php script via cron?
| |
|
|
| Colin McKinnon 2005-08-30, 6:56 pm |
| ZeldorBlat wrote:
> getenv('USER');
>
> http://www.php.net/manual/en/function.getenv.php
Yeah, right.
Kleist wrote:
> I know that it rother not strict PHP question, but
> nevertheless, I'd like to know how to get username of the
> user who has run CLI php script via cron?
Might help if you told us what system this is on. If it's a Linux box you
could use:
$user=`id -un`;
or on most Unix boxes:
$user=`whoami`;
C.
| |
| Kleist 2005-08-31, 3:56 am |
| Colin McKinnon wrote:
>
> Might help if you told us what system this is on. If it's a Linux box you
> could use:
> $user=`id -un`;
> or on most Unix boxes:
> $user=`whoami`;
>
Yes, it's Linux box, and $GLOBALS['USER'] does good enough
if one calls the script from command line. But I wonder, if
the script will be fired up from cron, will this variable
store the proper value. Username stored in field "name" in
the crontab. Cron runs under another user
|
|
|
|
|