/*
 * LanzarOndarenet.java
 *
 */
package org.dspace.administer;

import java.sql.SQLException;

import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import java.io.*;
import org.dspace.core.ConfigurationManager;

import org.dspace.storage.rdbms.DatabaseManager;

public class LanzarOndarenet
{
	
	
    public static void main(String[] argv)
    	throws Exception
    {
    	
    	Context c = new Context();
    	c.setIgnoreAuthorization(true);
      
      try { 

					Process p = Runtime.getRuntime().exec("/aplic/x20/dspace/bin/ondarenet"); 
					InputStream stderr = p.getErrorStream();	
					InputStreamReader isr = new InputStreamReader(stderr);
					BufferedReader br = new BufferedReader(isr);
					
					InputStream stdin = p.getInputStream();	
					InputStreamReader isr2 = new InputStreamReader(stdin);
					BufferedReader br2 = new BufferedReader(isr2);
					String line = null;
					String line2 = null;
					
					
					while ( (line2 = br2.readLine()) != null)
						System.out.println(line2+"<br>");
						
					while ( (line = br.readLine()) != null)
						System.out.println(line+"<br>");
						
					
					int exitVal = p.waitFor();
					System.out.println("Process exitValue: " + exitVal);
     
					//p.destroy();
				
					System.out.println("Proceso completado");
					

				} 
				catch (IOException e){ 
					/* Se lanza una excepción si no se encuentra en ejecutable o el fichero no es ejecutable. */ 
					System.out.println("excepcion Process");								
				}		
      
      
      
    	c.complete();
    	
    }
    
    	   				
    
}
