Does whoami exists in Erlang?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Does whoami exists in Erlang?

Sean Hinde-2
> Hi,
>
> I like to write a configfile into the users-home directory,
> but therefore
> I need to know the current username. Does in Erlang something
> like "whoami" exists like in unix?

You can always use:

1>os:cmd("whoami").
"sean/n"
2>

or even:

2>os:cmd("echo $HOME").
"/export/home/sean/n"
3>

which will give you the home directory of the user who started the beam
process (barring no doubt some determined effort by the user to hide this..)

Sean



NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.



Reply | Threaded
Open this post in threaded view
|

Does whoami exists in Erlang?

Luke Gorrie-3
Sean Hinde <Sean.Hinde> writes:

> > Hi,
> >
> > I like to write a configfile into the users-home directory,
> > but therefore
> > I need to know the current username. Does in Erlang something
> > like "whoami" exists like in unix?
>
> You can always use:
>
> 1>os:cmd("whoami").
> "sean/n"
> 2>
>
> or even:
>
> 2>os:cmd("echo $HOME").
> "/export/home/sean/n"
> 3>
>

And yet another is

  1> os:getenv("HOME").
  "/home/luke"

Cheers,
Luke