[3150] | 1 | function issmscpout(host,path,login,port,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
|
---|
| 9 | hostname=oshostname();
|
---|
| 10 |
|
---|
| 11 | %if hostname and host are the same, do a simple copy
|
---|
| 12 |
|
---|
| 13 | if 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
|
---|
| 21 | else
|
---|
| 22 | if ispc,
|
---|
| 23 | %use the putty project pscp.exe: it should be in the path.
|
---|
| 24 |
|
---|
[12155] | 25 | %get ISSM_DIR variable
|
---|
| 26 | [status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
|
---|
[3150] | 27 | if status,
|
---|
[12743] | 28 | error('scpout error message: could not find ISSM_DIR_WIN environment variable');
|
---|
[3150] | 29 | end
|
---|
[12155] | 30 | ISSM_DIR=ISSM_DIR(2:end-2);
|
---|
[3150] | 31 |
|
---|
| 32 | username=input('Username: (quoted string) ');
|
---|
[9369] | 33 | key=input('Key: (quoted string) ');
|
---|
[3150] | 34 |
|
---|
| 35 | for i=1:numel(packages),
|
---|
[12155] | 36 | [status,result]=system([ISSM_DIR '/externalpackages/ssh/pscp.exe -l "' username '" -pw "' key '" ' packages{i} ' ' host ':' path]);
|
---|
[3150] | 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 |
|
---|
| 51 | if port,
|
---|
| 52 | eval(['!scp -P ' num2str(port) ' ' string ' ' login '@localhost:' path]);
|
---|
| 53 | else
|
---|
| 54 | eval(['!scp ' string ' ' login '@' host ':' path]);
|
---|
| 55 | end
|
---|
| 56 | end
|
---|
| 57 | end
|
---|