Solved

changing linux user name in jsp page

Posted on 2004-08-24
2
320 Views
Last Modified: 2010-04-01
Hello all

in my jsp code below I am able to execute some linux commands like

    whoami

or

    uptime

what i need to do is change the user that is logged in on linux (from my jsp page) so that when files are created it will show that the username is different then root.

files created ony my jsp page have the owner of root by default

i am not talking about the environment variable user by the way

from root on linux one can execute the command

                       su newuser

is it possible to do something like this from my jsp ?




Process p2 = Runtime.getRuntime().exec("touch /home/iceman/new_file");
Process p3 = Runtime.getRuntime().exec("chown iceman:finnigan /home/iceman/new_file");

these lines of code worked on my jsp - ie a file was created and then the owner and group for that file were changed



//process p2 = Runtime.getRuntime().exec("su newuser"); - does not work
Process p = Runtime.getRuntime().exec("whoami");  - works
BufferedReader print = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line =  print.readLine();
out.print(line)

i dont need output for changing the user

what i need it for is that a qsub command will be run later and specific user name must be logged in for that qsub command to work


thank you

bryan

0
Comment
Question by:bryanberg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
ramazanyich earned 500 total points
ID: 11889724
Runtime.getRuntime().exec("su - newuser -c qsub");
0
 

Author Comment

by:bryanberg
ID: 11899516
ahhhh

thank you much

we havent tried the qsub command yet but we put the whoami command on the same line

and sure enuf the user was changed

kudos to you !! : >
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
Learn why we support net neutrality and why the topic is important to all internet users.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question