Erros

bom dia!
Estou com um problema com java, me perdoem mas ainda nao tenho tanto conhecimento…
estou usando java no oracle 10g para executar comandos unix…tipo chmod, copy etc,
eu nao consigo retorna um inputstream que eu preciso para ler as linhas do comando que volta as variaveis de ambiente…
aqui vai o codigo

private static InputStream ExecuteComand(String cmd) {
        boolean STDOUT = false;
        boolean STDERR = false;
        boolean LOGGER = true;
        InputStream so = null;
        InputStream se = null;
        Thread o = null;
        Thread e = null;
        int rc = -1;
        String error = "Error inproper call";
        FileOutputStream fos = null;

        try {
            STDERR = true;
            STDOUT = true;
            //System.out.println(cmd);
            Runtime rt = Runtime.getRuntime();
            Process p = rt.exec(cmd);
            so = p.getInputStream();
            se = p.getErrorStream();
            
                     
            if (STDOUT) {
                capture(so, fos, "SAIDA", o);
                 }

            if (STDERR) {
                capture(se, null, "ERRO", e);
            }

            try {
                rc = p.waitFor();
            /* Handle exceptions for waitFor() */
            } catch (InterruptedException intexc) {
                System.out.println("Interrupted Exception on waitFor: " +
                        intexc.getMessage());
            }

	            if (o != null) {
                o.join();
                o =null;
            }

            if (e != null) {
                e.join();
                e =null;
            }

            if (fos != null) {
                fos.flush();
                fos.close();
            }
            se.close(); 
            so.close();
            System.out.println("ExitValue: " + rc);
         

        } catch (Throwable t) {
            System.out.println("ExitValue: " + rc);
            t.printStackTrace();
        } finally {
            if (LOGGER) {
                LogCmd(error, rc);
                STDOUT =false;
                STDERR =false;
                LOGGER =true;
            }
        }
        System.out.println("executou até o final");
        return so;
        
    }

e dá este erro qdo eu tento pega o retorno com objeto inputstream em outro método
java.io.IOException: Pipe closed
at java.io.PipedInputStream.read(PipedInputStream.java)
at oracle.aurora.java.lang.OracleProcess$ProcessInputStream.read(OracleProcess.java)
at java.io.PipedInputStream.read(PipedInputStream.java)
at java.io.InputStream.read(InputStream.java)
at java.io.InputStreamReader.fill(InputStreamReader.java)
at java.io.InputStreamReader.read(InputStreamReader.java)
at java.io.BufferedReader.fill(BufferedReader.java)
at java.io.BufferedReader.readLine(BufferedReader.java)
at java.io.BufferedReader.readLine(BufferedReader.java)
at ExecOSCmdRestrict.ValidateDir(ExecOSCmdRestrict.java:79)
at ExecOSCmdRestrict.ChmodFile(ExecOSCmdRestrict.java:26)

    private static boolean ValidateDir(String dir) {
        // Validate directories on Oracle init file searching for UTL_FILE_DIR
        boolean STDOUT = false;
        boolean STDERR = false;
        boolean LOGGER = true;
        boolean dirok = false;
        //String initFile = null;
        String envVariable = "/bin/env" ;
              
        try {
            STDERR = true;
            STDOUT = true;
            String linha;
            String initFile = null;
            InputStream initLine = null;
            
            /*initLine = ExecuteComand(envVariable);
            InputStreamReader Ix = new InputStreamReader(initLine);
            BufferedReader ll = new BufferedReader(Ix);
            
            Runtime rt = Runtime.getRuntime();
            Process p = rt.exec(envVariable);
            InputStream so = p.getInputStream();*/
            
            initLine = ExecuteComand(envVariable);
            InputStreamReader Ix = new InputStreamReader(initLine);
            BufferedReader ll = new BufferedReader(Ix);
            String sid = "ORACLE_SID";
            String home = "ORACLE_HOME";
            
            while ((linha = ll.readLine()) != null) {
                    System.out.println("OUTPUT = " + linha);
                   if(linha.indexOf(home) != -1){
                     int be = linha.lastIndexOf("=");
                     be ++;
                     home = linha.substring(be);
                     System.out.println(" ACHOU = " + home);
                    }
                   if(linha.indexOf(sid) != -1){
                     int be = linha.lastIndexOf("=");
                     be ++;
                     sid = linha.substring(be);
                     System.out.println(" ACHOU = " + sid);
                    }
                   if (linha.length() < 1) {
                    System.out.println("Error: Enviroment $ORACLE_HOME and $ORACLE_SID não iniciada!");
                    System.exit(1);
                   }
            }
            
            /*
            initLine = ExecuteComand("/usr/bin/grep UTL_FILE " + home + sid);
            BufferedReader lll = new BufferedReader(new InputStreamReader(initLine));
            
            while ((linha = lll.readLine())!=null) {
                if (linha.substring(10).equalsIgnoreCase(dir))   {
                    return true;
                    break;
                }

            }*/
            return false;
         

        } catch (Throwable t) {

            System.out.println("ExitValue: ");

            t.printStackTrace();

        } finally {

            if (LOGGER) {

                STDOUT = false;

                STDERR = false;

                LOGGER = true;

            }

        }
        return false;
    }

Este é o código que eu pego de volta para ler as linhas…