Use jsp pages to connect to a UNIX server

Posted on 2005-04-29
Medium Priority
Last Modified: 2008-01-09

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.

Question by:sushiltanna
LVL 19

Accepted Solution

Kuldeepchaturvedi earned 2000 total points
ID: 13894570
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) {

Expert Comment

ID: 13898594
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.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In the below post we have mentioned the best hosting type for startups. Also, check out some of the superlative web hosting companies that are proposing affordable web hosting solutions to host your startup website.
Last month Marc Laliberte, WatchGuard’s Senior Threat Analyst, contributed reviewed the three major email authentication anti-phishing technology standards: SPF, DKIM, and DMARC. Learn more in part 2 of the series originally posted in Cyber Defense …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 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