public void execCommand(Connection conn, String cmd,
			ArrayList<String> list, ArrayList<String> errorList) throws RemoteException {

		try {
			/* Create a session */
			Session sess = conn.openSession();
			sess.execCommand(cmd);

			/*
			 * get the printed information of stdout and stderr.
			 */
			InputStream stdout = new StreamGobbler(sess.getStdout());
			br = new BufferedReader(new InputStreamReader(stdout));
			InputStream stderr = new StreamGobbler(sess.getStderr());
			errorbr = new BufferedReader(new InputStreamReader(stderr));

			while (true) {
				line = br.readLine();
				if (line == null)
					break;
				list.add(line);
			}

			while (true) {
				errorline = errorbr.readLine();
				if (errorline == null)
					break;
				errorList.add(errorline);
			}

			/* Close this session */
			sess.close();

		} catch (IOException e) {
			throw new RemoteException(e.getMessage());
			
		}
	}