Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

linux commands from JSP page

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

How can i run linux commands from JSP page??

I have written one class which has one method which kills process.

But when i call it from jsp page its not working...

Why so?

Regards,
Isha
 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can check out the method Runtime.getRuntime()

Usage :-

Runtime.getruntime().exec("ls");
 
shah isha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for your reply,

I have written the same code in my one java class. Its working too when i run it.

But when i import it in my jsp file and trying to run it on click.. its not working..

Why so??

Regards,
Isha
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by shah isha:
Hi all,

How can i run linux commands from JSP page??

I have written one class which has one method which kills process.

But when i call it from jsp page its not working...

Why so?

Regards,
Isha



Why exactly are you killing processes from a JSP page ? That is not what a JSP is meant for. Can you post some code ?
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does your JSP page work? If you add some HTML code to it, do you see it on the screen?
Does calling the class from JSP page work? If you add some println statements in your class, do they get printed out (most likely to your web container's log file).
If that works, maybe there are some security restrictions on JSP (kind of like on Applets when they're not allowed to do everything what a regular Java application can)?
 
shah isha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ John Meyers

Hi,

I am developing administration part of network management.

In which admin can view process running on some computer and can kill it by clicking on button. This coding is done in jsp.

Regards,
Isha
 
shah isha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Andris Jekabsons

Hi,

Ya my code is running perfectly fine.
In fact i have another function which is not having any linux commands in the same class where i have kept function to kill process.

That function is working from jsp but not the one which is killing process.

Regards,
Isha
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it does not work in a JSP, call a servlet that will kill the process for you and then redirect you to a JSP page that dynamically lists down active processes. Do you see any error stacks when you use the code in a jsp ?
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wonder whether you had efficient priviledge to run kill command. Before running killing command in jsp, would you add code to check what your userid was? eg. "whoami".
 
reply
    Bookmark Topic Watch Topic
  • New Topic