| 8616 |
vikram.rag |
1 |
package utilities;
|
|
|
2 |
|
|
|
3 |
import java.util.Arrays;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
|
|
|
6 |
import org.apache.tools.ant.Project;
|
|
|
7 |
import org.apache.tools.ant.taskdefs.optional.ssh.Scp;
|
|
|
8 |
|
|
|
9 |
import in.shop2020.config.ConfigException;
|
|
|
10 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
|
|
11 |
import org.apache.log4j.Logger;
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
public class ScpService {
|
|
|
15 |
|
|
|
16 |
public List<String> ips;
|
|
|
17 |
public String keyFile;
|
|
|
18 |
|
|
|
19 |
public void scpFile( String remoteFilePath, String localFilePath ){
|
|
|
20 |
|
|
|
21 |
List<String> ips = Arrays.asList("192.168.179.131,178.79.184.36".split(","));
|
|
|
22 |
keyFile= "/root/.ssh/id_dsa.pub";
|
|
|
23 |
for(int i=0;i<ips.size();i+=1){
|
|
|
24 |
Scp scp = new Scp();
|
|
|
25 |
scp.setFile(localFilePath);
|
|
|
26 |
scp.setKeyfile(keyFile);
|
|
|
27 |
scp.setRemoteTodir("root: @"+ips.get(i)+":"+remoteFilePath);
|
|
|
28 |
scp.setProject(new Project());
|
|
|
29 |
scp.setTrust(true);
|
|
|
30 |
scp.execute();
|
|
|
31 |
}
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
public static void main(String[] args) throws ConfigException {
|
|
|
35 |
ScpService scp = new ScpService();
|
|
|
36 |
scp.scpFile("/var/lib/tomcat6/webapps/export/banners/banner1.jpg", "/var/lib/tomcat6/webapps/export/banners/banner1.jpg");
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
}
|