This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I have wriiten java class to excute on Unix machine.The UNIX user ID is passed through command line arguments to this java class and have to perform all the work as that user which passed thru command line arguments.How to change the UNIX user using user ID in JAVA ?
Thats a good aspect. Thanks. I have never come across.
Have been googling around by the time I posted my first reply here .
I have NOT got any satisfied and straight forward results so far.
But to give you a work around, you can first issue a native command of switching user ("su <userEnteredInCommandLine>") via the external process you launched. This would effectively change the user for running the program. Subsequently you can run the java program you wish to run.
Pseudo code :
Does that help?
But I just doubt would there be a continuity between these two attempts!.
Meanwhile, If I get another solution/work around shall post it here. Good luck
Once you su you're that user until you exit the su shell.
sudo will run a given command on the command line and you'll be the original user when the command has completed.
Thats great David. Thanks for the clarification.
However, we are NOT really using the shell here. Right? It is through an external process he is using via/through Java. Hence i doubted on the effect of 'su' for the subsequent commands. Hope I made it clear.