All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.tweetyproject.commons.util.Shell Maven / Gradle / Ivy

There is a newer version: 1.27
Show newest version
/*
 *  This file is part of "TweetyProject", a collection of Java libraries for
 *  logical aspects of artificial intelligence and knowledge representation.
 *
 *  TweetyProject is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License version 3 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program. If not, see .
 *
 *  Copyright 2016 The TweetyProject Team 
 */
package org.tweetyproject.commons.util;

import java.io.IOException;

/**
 * @author Nils Geilen
 * Provides several ways to run unix commands on different OSes.
 */
public abstract class Shell {
	private static Shell nat = new NativeShell();
	
	/**
	 * a wrapper for the os' native shell
	 * @return  a wrapper for the os' native shell
	 */
	public static Shell getNativeShell(){
		return nat;
	}
	
	/**
	 * a wrapper around the cygwin shell
	 * @param binary path to bash.exe
	 * @return  a wrapper for the os' native shell
	 */
	public static Shell getCygwinShell(String binary){
		return new CygwinShell(binary);
	}
	
	/**
	 * runs command 
	 * @param cmd the command to be run
	 * @return the terminal output
	 * @throws InterruptedException if some interruption occurred.
	 * @throws IOException if some IO issue occurred.
	 */
	public abstract String run(String cmd) throws InterruptedException, IOException;
}










© 2015 - 2024 Weber Informatics LLC | Privacy Policy