source: issm/trunk/src/m/utils/OS/scpout.m@ 2306

Last change on this file since 2306 was 2306, checked in by Mathieu Morlighem, 15 years ago

use symlink instead of copyfile if job is launched locally

File size: 1.4 KB
Line 
1function scpout(host,path,packages)
2%SCPOUT send packages to a host, using scp on unix, and pscp on windows
3%
4% usage: scpout(host,path,packages)
5%
6%
7
8%get hostname
9hostname=oshostname();
10
11%if hostname and host are the same, do a simple copy
12
13if strcmpi(host,hostname),
14 for i=1:numel(packages),
15 here=pwd;
16 eval(['cd ' path])
17 system(['rm -rf ' packages{i} ]);
18 system(['ln -s ' here '/' packages{i} ' .']);
19 eval(['cd ' here]);
20 end
21else
22 if ispc,
23 %use the putty project pscp.exe: it should be in the path.
24
25 %get ISSM_DIR variable
26 [status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
27 if status,
28 error('scpout error message: could not find ISSM_DIR_WIN envirnoment variable');
29 end
30 ISSM_DIR=ISSM_DIR(2:end-2);
31
32 username=input('Username: (quoted string) ');
33 password=input('Password: (quoted string) ');
34
35 for i=1:numel(packages),
36 [status,result]=system([ISSM_DIR '/externalpackages/ssh/pscp.exe -l "' username '" -pw "' password '" ' packages{i} ' ' host ':' path]);
37 if status,
38 error('scpout error message: could not call putty pscp');
39 end
40 end
41
42 else
43 %just use standard unix scp
44 %create string of packages being sent
45 string='';
46 for i=1:numel(packages),
47 string=[string ' ' packages{i}];
48 end
49 string=[string ' '];
50 [status,result]=system(['scp ' string host ':' path]);
51 if status,
52 error('scpout error message: could not call scp on *nix system');
53 end
54 end
55end
Note: See TracBrowser for help on using the repository browser.