View Full Version : system commands


twidup
05 May 2005, 04:27 PM
anyone know what the system commands are for finding out who the current user is?
for Windows, linux and osx?

thanks
-todd

Scott212
05 May 2005, 08:33 PM
If I remember right it's these:

Mac OSX:
who Print all usernames currently logged on
whoami Print the current user id and name (`id -un')

Windows XP:
WHOAMI Output the current UserName and domain

Linux:
who Print all usernames currently logged in
whoami Print the current user id and name (`id -un')


Being UNIX based, the OSX and Linux commands should be similar if not the same.

Good Luck!

twidup
05 May 2005, 09:00 PM
hmmm, WHOAMI doesnt seem to work with a system command.

I was able to get what I wanted with system "%USERNAME%" though, so that works, will have to try the others at work tomorrow


thanks
-todd

Scott212
05 May 2005, 10:23 PM
Here's where I found the information: http://www.ss64.com/
perhaps you can find something better suited for what your up to...

twidup
05 May 2005, 12:00 AM
yup, thats exactly where I found it at.

Thanks for the help though, I will check the linux and osx commands tomorrow and see what they spit out.

thanks
-todd

Scott212
05 May 2005, 12:23 AM
GOT IT!

Windows XP recognizes: SET USERNAME

if you just type in SET, you'll get a whole buttload of interesting returns. Enjoy!

twidup
05 May 2005, 12:46 AM
sweet, that helps even more. some info in set that I was already getting another way..thanks heaps for that one.

-todd

Scott212
05 May 2005, 12:48 AM
I love to help. However, if ya get bored and can shed any light on this one: http://www.cgtalk.com/showthread.php?t=216588

It's got me real buggered up.

:twisted:

DangerAhead
05 May 2005, 12:26 AM
You guys know how to query the computer's name? On a PC?

I need to have a script run only when it's on the render server, not on a workstation, and all i need to get the script working is the ability to query the computer name.

DangerAhead
05 May 2005, 12:43 AM
you can get it by using the following:


string $queryName = `system("set computername")`;
string $computerName[] = stringToStringArray( $queryName, "=");
print ("this computer's name is " + $computerName[1]);

Scott212
05 May 2005, 01:09 AM
set returns a bunch of fun stuff!

macaroniKazoo
05 May 2005, 11:38 PM
to get the username:
string $user = `getenv user`;

to get the computer name:
string $comp = `getenv computername`;

chalbers
05 May 2005, 07:18 AM
In Linux:

string $user = `getenv USER`

Frank

chalbers
05 May 2005, 07:47 AM
In Linux:

string $user = `getenv USER`

Frank

Actually it also works on windows.

macaroniKazoo
05 May 2005, 09:47 PM
yeah, thats why I said it in my post, right before yours. ;)

chalbers
05 May 2005, 11:52 PM
Heh ! Only read the first message ..

yeah, thats why I said it in my post, right before yours. ;)

macaroniKazoo
05 May 2005, 11:53 PM
heh, yeah, i think we're all guilty of that crime from time to time... ;)

BTmonkey
06 June 2005, 09:19 AM
@_@!
@_@!

@_@!

@_@!

@_@!

@_@!

@_@!

@_@!

CGTalk Moderation
06 June 2005, 09:19 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.


1