[ Back | Previous | Next ]

How to execute a script with Runtime and catch the output of Process?

Package:
java.lang.*
Product:
JDK
Release:
1.0.2
Related Links:
General
General
General
General
General
General
General
General
General
Runtime
System
Comment:
		File f = new File(location + documenturl);
		if (!f.exists()) {
			res.sendError(HttpServletResponse.SC_NOT_FOUND, "Can't read or find the requested document at location: " + location + documenturl + "\n
" + f.getAbsolutePath()); System.out.println("-- can't read or find the requested document at location: " + location + documenturl + "\n
" + f.getAbsolutePath()); Process p = rn.exec("ls -als " + documenturl); DataInputStream st = new DataInputStream(p.getInputStream()); String buf = " "; boolean loop = true; while ((buf = st.readLine()) != null) res.getOutputStream().println(buf); st.close(); if (p.exitValue() != 0) System.err.println("error !!"); return; }