trying to open a shell using Runtime.exec()

topic posted Fri, July 29, 2005 - 2:10 PM by  ~cec~
Share/Save/Bookmark
Advertisement
Hey all,

I am creating a service that opens a specialized shell and keeps track of that process by entering it into a hashtable. The initialization uses a checkForPrompt function that searches the InputStreams for a special character, ie '$' or ']'. However when I start the process on Linux, no prompt appears. (Ironically this works on Windows.) A snippet of my code:

Process ps = null;
InputStream in, err;
exec = "bash";

try
{
ps = m_runtime.exec(exec);

in = ps.getInputStream();
err = ps.getErrorStream();
while(!timeout){
tmpIn = readFromStream( in, "in" );
if(checkForPrompt(tmpIn))
return true;
}
else
timeout++;

}
.
.
.

Will the process ever return a prompt? Is there a better way to do this or check to see if the shell has been entered?

Thanks!
Cecilia
posted by:
~cec~
SF Bay Area
Advertisement
Advertisement

Recent topics in "Java Monkeys"

Topic Author Replies Last Post
Javascripting costs Schirin 3 May 17, 2007
Design patterns and principles emblylan 6 February 14, 2007
open source hosting alternatives? Mark 2 February 3, 2007
Ruby > Java Unsubscribed 6 January 9, 2007