----- Original Message -----
From: "Sureka, Sushil" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Wednesday, August 13, 2008 8:16 PM
Subject: Reading environment variable from Tomcat
Hi,
I have run into an issue related to starting tomcat as a service. When
we were starting tomcat from the command line, we were able to just say
System.getProperty("user.name" ) to retrieve the logged in user id. But
now that we start tomcat using a service, the get property call returns
"SYSTEM".
After doing some more research, it seems like I have two options to find
out the login id.
1. Start the service using logged on option.
2. Use System.getEnv()
It seems like the first option may not work for us as our passwords
expires periodically, and setting the logon/password account means that
we would have to have manual intervention. Additionally, when I tried
use my user id as logon id, it won't let me do that ( I imagine I need
to have system admin turn the privilege on for or something on those
lines)
The second option did not work either. Calling the
System.getEnv("USERNAME") in a program started from the command line
returns the logged in user name, but it returns null when tomcat was
started using service approach.
I am not sure if there is a way to find out who is logged in into the
system when Tomcat has been started using service mechanism. Any help in
this matter would be great help
SS
---------------------------------------
Sureka,
A service is like a completely diff user, eg you dont even have to log into
a machine and it will run, thus it defaults to SYSTEM, and you can change
it, but its always a diff user...
You could possibly do some tricks like call some MS functions, but you see
the immediate problem is the service is already running long before anyone
has logged in... so when would you do that...
Here a thought... MS has a RUN folder, what ever you put in there starts
when the user starts... so you can hook it up that way...
... but the big question is... why are you doing it, and why are you even
assuming anyone is logged in...
Before you make work for yourself... maybe bouncing the concept off the
guru's in here is a good idea... what it is you actually trying to do?
Your Java stuff wont work because all that stuff you looking for is setup as
the VM starts... the service has a diff one to whatever the user is doing...
Normally a user would be logging into TC itself... and thus TC would know
who it is...
Have fun ;)
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]