Use jsp pages to connect to a UNIX server


I need to create a solution wherein a jsp site talks to applications running on UNIX server. For starters lets say - a jsp request sent to check the status of any UNIX process by running a 'ps' command on UNIX. I would like to get the result of the 'ps' command and should be able to display the same on the web.

I am pretty new to the jsp domain - please suggest a solution ASAP and in a very basic fashion.

Any pointers to articles, tutorials, books online will also be appreciated.

Thanks in advance.

Who is Participating?
KuldeepchaturvediConnect With a Mentor Commented:
you can use System.runtime to run the process on the unix server..
pre-requesite is that your jsp shd be running on that same server....
code sniplett will look something like..
  String ls_str;

          Process ls_proc = Runtime.getRuntime().exec("/bin/ls -aFl");

          // get its output (your input) stream

          DataInputStream ls_in = new DataInputStream(

          try {
            while ((ls_str = ls_in.readLine()) != null) {
          } catch (IOException e) {

      } catch (IOException e1) {
One more example

          Runtime runTime = Runtime.getRuntime();
          Process process = runTime.exec ("/bin/ps");
          InputStream inputStream = process.getInputStream();
          InputStreamReader   inputStreamReader = new InputStreamReader (inputStream);
          BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
          String line = null;
         while ( (line = bufferedReader.readLine()) != null )
         int exitVal = process.waitFor();
         out.println ("Process exitValue:  " + exitVal );
          catch (Throwable t)

In the above code bufferedReader.readLine() will read all the lines that are printed by the 'ps' command and print on the page.process.waitFor() will return the exit value of the command.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.