LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-19-2011, 03:40 PM   #1
etika
Member
 
Registered: Dec 2010
Posts: 38

Rep: Reputation: 0
how to run linux command from a different user from a jsp page which is run by tomcat


hello



<%@ page import="java.io.*"%>
<%

try
{
Process p=null;
Runtime r=Runtime.getRuntime();
String cmd="sh /bin/date>/home/etika/Desktop/aaa/mm.txt";
p=r.exec(cmd);
p.waitFor();

}

catch(Exception e)
{
out.println(e);
}
%>







information:
tomcat6 is running my jsp page ,so all the linux commands too are executed by tomcat6.
but i want to run these linux commands from a different user etika on my system through this jsp page which is executed by tomcat.

(on running the linux commannd the ownership of the file gets change to tomcat6 but i don't want the ownership of the file to be changed on executing it ,so can i run this linux command from a different user etika so that my ownership doesnot changes )
 
Old 04-19-2011, 03:53 PM   #2
lisle2011
Member
 
Registered: Mar 2011
Location: Surrey B.C. Canada (Metro Vancouver)
Distribution: Slackware 2.6.33.4-smp
Posts: 183
Blog Entries: 1

Rep: Reputation: 25
well that is your first clue - the change of ownership

read the Tomcat manual concerning users and groups, generally speaking the user running the Tomcat server is the only one
allowed to run executables, the web page may seem to be being run by whomever is on it but
only the user running Tomcat is able to execute. Doing otherwise leads to a crisis of security.
 
Old 04-27-2011, 12:53 PM   #3
lisle2011
Member
 
Registered: Mar 2011
Location: Surrey B.C. Canada (Metro Vancouver)
Distribution: Slackware 2.6.33.4-smp
Posts: 183
Blog Entries: 1

Rep: Reputation: 25
You should mark this post as SOLVED
 
0 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing mysql Db from jsp page using tomcat Tekken Linux - Server 2 06-29-2009 12:55 AM
how to run system commands from jsp page robin singh Linux - Newbie 8 03-07-2009 11:28 AM
non-root user unable to run tomcat with usb ports mar38 Linux - Software 0 07-21-2004 03:45 AM
Want to run debugger through JSP page... kirti Linux - Software 0 06-10-2004 08:25 AM
user under which apache tomcat run?? Sridhar Guntur Linux - Security 2 08-28-2003 02:06 PM


All times are GMT -5. The time now is 06:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration