Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling system binaryies from your servlet  RSS feed

 
Brendan Kennedy
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sry, this seems to be a very newbyish question, but I can't seem to find the answer anywhere:
This is on a Free BSD system. I want to call the 'finger' command and output the results into the a webpage from my servlet. Does anybody know how? Could you post some sample code for me?? I know it's going to be something like : -
try
{
Process pr = Runtime.getRuntime().exec("/usr/bin/finger");
out.println(pr.toString());
}
catch (IOException e)
{
System.out.println("ERROR: " + e + "\n ");
}
But that only outputs:
java.lang.UNIXProcess@508fc5d
thanks,
Brendan
 
David Freels
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to get the InputStream and read the data.
process.getInputStream();
Writing to the outputstream will also allow you to interact with the program.
David
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!