summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/satserver/util/Exec.java
blob: 1f810ebe2a74f6e9eccb53791231551c1e0246da (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.openslx.satserver.util;

import java.io.File;
import java.io.IOException;

public class Exec
{

	/**
	 * Run command, return exit status of process, or -1 on error
	 * 
	 * @param command Command and arguments
	 * @return exit code
	 */
	public static int sync( String... command )
	{
		ProcessBuilder pb = new ProcessBuilder( command );
		pb.directory( new File( "/" ) );
		Process p;
		try {
			p = pb.start();
			return p.waitFor();
		} catch ( IOException | InterruptedException e ) {
			return -1;
		}
	}

}