java调用linux命令传输远程大文件

public class LinuxCall {
	
	public static void main(String[] args) {
//		String[] cmdArray = new String[]{
//				"scp /usr/bin/qpress 192.168.11.201:/usr/bin/qpress",
//				"ssh 192.168.11.201 \"nc -l 2777 |  qpress -dio > /home/dev1/file_test/Webos.zip\" &",
//				"qpress -o /home/qabipw/file_test/Webos.zip |nc 192.168.11.201 2777"};
		try {
			System.out.println(System.currentTimeMillis()+"___Linux大文件传输命令执行开始...");
			Process proc = Runtime.getRuntime().exec("scp /home/dev1/file_test/Webos.zip [email protected]:/home/build1/file_test/");
//			int exitResult = proc.exitValue();
//			if(exitResult != 0) {
//				System.out.println("Linux大文件传输命令执行失败:\n");
//				BufferedReader brin = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
//				String linein = null;
//				while ((linein = brin.readLine()) != null) {
//					System.out.println(linein+"\n");
//				}
//			} else {
//				System.out.println(System.currentTimeMillis()+"___Linux大文件传输命令正常执行完成...");
//			}
			System.out.println(System.currentTimeMillis()+"___Linux大文件传输命令执行开始...");
			BufferedReader brin = new BufferedReader(new InputStreamReader(proc.getInputStream()));
			String linein = null;
			while ((linein = brin.readLine()) != null) {
				System.out.println(linein+"\n");
			}
			
			System.out.println(System.currentTimeMillis()+"___Linux大文件传输命令执行完成...");
		} catch (IOException e) {
			System.out.println("Linux大文件传输命令执行过程中出现异常:"+e.toString());
			e.printStackTrace();
		}
	}

}

你可能感兴趣的:(远程文件传输,java调用linux命令)