Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Calling shell script from a Servlet.

Reply
Thread Tools

Calling shell script from a Servlet.

 
 
Liza
Guest
Posts: n/a
 
      11-01-2003
Hi, I'm trying to call a shell script from a standalone Java App and
from a Servlet. I have no problems executing the two following lines
in a regular Java program:
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(" bash /usr/bin/mydir/myscript.sh");

When I try to do the same thing from a Servlet I get nothing. Is that
because Tomcat should be able to find a directory where shell script
resides? Should I put a symbolic link somewhere in Tomcat home
directory to the directory where shell script resides? Or there is
some other problem with calling a shell script from the servlet?
Thanks in advance.
N.K.
 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      11-03-2003
Liza wrote:

> Hi, I'm trying to call a shell script from a standalone Java App and
> from a Servlet. I have no problems executing the two following lines
> in a regular Java program:
> Runtime runtime = Runtime.getRuntime();
> Process process = runtime.exec(" bash /usr/bin/mydir/myscript.sh");
>
> When I try to do the same thing from a Servlet I get nothing. Is that
> because Tomcat should be able to find a directory where shell script
> resides? Should I put a symbolic link somewhere in Tomcat home
> directory to the directory where shell script resides? Or there is
> some other problem with calling a shell script from the servlet?
> Thanks in advance.
> N.K.


More likely it is that bash is not in the path in the environment where
your process runs. You should specify an absolute path to it. (Always
a good idea security-wise, anyway.) You have already specified an
absolute path to the script, so finding it should not be a problem
unless Tomcat has been subjected to a chroot, or something like that.
It could, however, be an access permission issue -- the user account or
group under which Tomcat runs must have read access to the script (and
read / execute to bash, and possibly read and even execute on all the
directories from root to each).


John Bollinger
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using subprocess module to launch a shell shell script that itselfforks a process Samuel A. Falvo II Python 0 10-08-2008 12:43 AM
Re: How to pass shell variable to shell script from python D'Arcy J.M. Cain Python 0 02-27-2008 01:56 PM
Re: How to pass shell variable to shell script from python Gerardo Herzig Python 1 02-27-2008 12:19 PM
Re: How to pass shell variable to shell script from python Christian Heimes Python 0 02-27-2008 10:53 AM
execute a shell script in a shell script moongeegee Perl Misc 2 12-04-2007 12:18 AM



Advertisments