Re: How to return user name in a script even if run by SUDO?



kapil singh kushwah wrote:
Hello ,

It is working fine. I guess you did it
after login as a root.

I am getting :

common@common-laptop:~$ echo ${USER}
common
common@common-laptop:~$ sudo echo ${USER}
common
common@common-laptop:~$


Thanks
Kapil Singh Kushwah
System/Network Administrator
Hotwax Media Inc.

sudo echo ${USER} will cause top level shell to expand ${USER} - i.e.
_BEFORE_ executing sudo. Hence you will see the same value with and
without sudo



--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



Relevant Pages

  • Re: How to return user name in a script even if run by SUDO?
    ... common@common-laptop:~$ sudo echo $ ... interpolated by the parent shell and *not* sudo. ...
    (Ubuntu)
  • Re: problem with include.
    ... function inside the IF block that was icluded in common. ... posts automatically by running PHP script. ... echo "Updating existing topic...\n"; ...
    (comp.lang.php)
  • Re: problem with include.
    ... function inside the IF block that was icluded in common. ... posts automatically by running PHP script. ... echo "Updating existing topic...\n"; ...
    (comp.lang.php)
  • Re: Possible to search ALL except filetype?
    ... Or I can narrow it down alittle bit or just put in the common .exts. ... I dump alot of images onto DVDs. ... that aren't the common picture types. ... Remove the word "echo" in the last line to activate the batch file. ...
    (microsoft.public.windowsxp.general)
  • Re: If() action within print()..?
    ... >> Don't assume I didn't look for the asnwer before I posted. ... > echo 'class2'; ... >> well, gimme a break. ... common sense isn't all that common. ...
    (comp.lang.php)