hmmm ... it returns : --- $? when I do this commant on one exec() : p = r.exec("cd /usr/local/cai; ./inocucmd -SEC -NEX /tmp/zavirovany.pif; echo $?");
ti returns nothing ... jdk is IBM JDK 1.3 ... <citováno kdo="Rakesh Menon"> > Change the code to : > > String line = in.readLine(); > while (line != null) { > ress = "<br>" + line; > line = in.readLine(); > } > > There is only one line to read, and its already read in > while(in.readLine() != null). After this, even if you try to read again > using in.readLine(), it will try to read next line, which is null. I > suggest to use ress as StringBuffer, if you expect more than 1 line and > use ress.append("<br>" + line). > > Hope this helps... > Thanks > Rakesh > > -----Original Message----- > From: Jiri Chaloupka [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 27, 2003 2:54 PM > To: [EMAIL PROTECTED] > Subject: trouble with readin value from Runtime.exec(cmd) > > > Hallo, > I have shell program, which I must call and read its output. On the > console it print some output to console and has some *return value*. > This return value I must read back to java: > > The part of code is: > **************************** > String ress = "---"; > Process p = null; > try{ > Runtime r = Runtime.getRuntime(); > p = r.exec("cd /usr/local/cai; ./inocucmd -SEC -NEX /tmp/file.pif; > echo $?"); > BufferedReader in = new BufferedReader(new > InputStreamReader(p.getInputStream())); > > while (in.readLine() != null) { > ress = "<br>"+in.readLine(); > } > in.close(); > }catch(Exception et){ > out.println("Fail: "+et.toString()); > } > out.println("<br>result is: "+ress+"<br>"); > *************************************************************** > but there is no value ... (in.readLine() conatins null) > > Is there anything what I not comprehed good? or where can be way? > > Thanks > Jiri > > ==========================================================================To > unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set > JSP-INTEREST DIGEST". > > Some relevant archives, FAQs and Forums on JSPs can be found at: > > http://java.sun.com/products/jsp > http://archives.java.sun.com/jsp-interest.html > http://forums.java.sun.com > http://www.jspinsider.com > > ==========================================================================To > unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set > JSP-INTEREST DIGEST". > > Some relevant archives, FAQs and Forums on JSPs can be found at: > > http://java.sun.com/products/jsp > http://archives.java.sun.com/jsp-interest.html > http://forums.java.sun.com > http://www.jspinsider.com -- Jiri Chaloupka B2BExpander.com [EMAIL PROTECTED] ********************************************** http://www.b2bexpander.com/ http://www.chalu.cz - intranet groupware solution =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com