There are some reserved variables that you should keep in mind for this
purpose (taken from "Perl in a Nutshell"):
$>
$EFFECTIVE_USER_ID
$EUID
The effective UID of the current process.
$<
$REAL_USER_ID
$UID
The real UID of the current process.
You can couple this with the function getpwuid() to return the actual user
name.
There may be a more effective way to do this, but here is an example script:
#!/usr/bin/perl
#
# Name: getpwuid.pl
# Author: Chris Hedemark <[EMAIL PROTECTED]>
# License: BSD
# Purpose: Demonstrate the getpwuid() function
# $< is a reserved variable for the current real UID of this process.
$uname = getpwuid($<);
print "$uname is the real user name running this process.\n";
# $> is a reserved variable for the current effective UID of this process.
$uname = getpwuid($>);
print "$uname is the effective user name running this process.\n";
----- Original Message -----
From: "Matija Papec" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 26, 2001 8:38 AM
Subject: whoami?
>
> Greetings,
>
> is there a more elegant way to find out who is running a script? %ENV is
> not reliable and it doesn't contain USER when booting the system, and
> "whoami" is external command(yuck :) ) tnx!
>
>
>
> --
> Matija
>