Yes there is one: yours!
From the Python doc:
getuser():
Return the ``login name'' of the user. Availability: Unix, Windows.
This function checks the environment variables LOGNAME, USER, LNAME and
USERNAME, in order, and returns the value of the first one which is set to a
non-empty string. If none are set, the login name from the password database
is returned on systems which support the pwd module, otherwise, an exception
is raised.
That's almost what you did in C++...
Cheers,
Aloys
On 8/10/06, Alan Jones <skyphyr(at)gmail.com> wrote:
> ooo - nice
> Is there a C++ crossplatform equivalent to this?
>
> Cheers,
>
> Alan.
>
> On 8/9/06, Aloys Baillet <aloys.baillet(at)gmail.com> wrote:
> > If you just want the logon username, independently of the platform, you
can
> > just use
> >
> > import getpass
> > username = getpass.getuser()
> >
> > my 2 cheap cents...
> >
> > Aloys
> >
> >
> > On 8/9/06, Alan Jones < skyphyr(at)gmail.com> wrote:
> > > name not main. what a great start to the day.
> > >
> > > On 8/9/06, Alan Jones <skyphyr(at)gmail.com> wrote:
> > > > Sorry Brad - damn Gmail - saw the main from the reply below.
> > > >
> > > > On 8/9/06, Alan Jones <skyphyr(at)gmail.com> wrote:
> > > > > I Bernard for the example of whoami you can instead use
environment
> > > > > variables to pull the same data.
> > > > >
> > > > > char * buffer;
> > > > > #ifdef Q_OS_WIN
> > > > > buffer = getenv ("USERNAME");
> > > > > #endif
> > > > >
> > > > > #ifdef Q_OS_DARWIN
> > > > > buffer = getenv ("USER");
> > > > > #endif
> > > > >
> > > > > #ifdef Q_OS_UNIX
> > > > > buffer = getenv ("USER");
> > > > > #endif
> > > > >
> > > > > That's the C++ edition, sorry - no python here.
> > > > >
> > > > > Cheers,
> > > > >
> > > > > Alan.
> > > > >
> > > > > On 8/8/06, Bradley Gabe < withanar(at)stanwinston.com> wrote:
> > > > > > I'm wondering if this is possible... I need to run os.system()
calls
> > > > > > through python, and I need to be able to see the line Python
echos
> > as a
> > > > > > result.
> > > > > >
> > > > > > So for example, if I want to run the command: whoami, I need to
get
> > the
> > > > > > string value that is echoed. The os.system() method itself just
> > returns
> > > > > > a number describing the status of the command.
> > > > > >
> > > > > > The purpose of this is to help in debugging Apache running mod
> > python,
> > > > > > which is doing strange things regarding permissions.
> > > > > >
> > > > > > Any help or advice appreciated!
> > > > > >
> > > > > > -Brad
> > > > > >
> > > > > > ---
> > > > > > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following
text in
> > body:
> > > > > > unsubscribe xsi
> > > > > >
> > > > >
> > > >
> > > ---
> > > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body:
> > > unsubscribe xsi
> > >
> >
> >
> >
> > --
> > Aloys Baillet - XSI Technical Director
> > Character Dpt - Animal Logic
> > --
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi
>
--
Aloys Baillet - XSI Technical Director
Character Dpt - Animal Logic
--