0

I am using the system as "user1" and I sudo as different user say "sudo -u user2 sbsh" and the execute a perl script.

Is there a way to get the "user1" in the script I am running ?

I used ENV{'USER'}. but it is giving "user2". 'SUDO_USER' is also not working.

1 Answers1

0

Try $ENV{'SUDO_USER'}.

Example:

$ sudo perl -E 'say for $ENV{USER}, $ENV{SUDO_USER}'
dolmen
  • 8,126
  • 5
  • 40
  • 42