Posted By:
Cecilia_B
Posted On:
Friday, July 29, 2005 06:24 PM
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(!timeou
More>>
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
<<Less