| 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 |
|
|---|
| 25 | %get ISSM_TIER variable
|
|---|
| 26 | [status,ISSM_TIER]=system('echo [%ISSM_TIER_WIN%]');
|
|---|
| 27 | if status,
|
|---|
| 28 | error('scpout error message: could not find ISSM_TIER_WIN envirnoment variable');
|
|---|
| 29 | end
|
|---|
| 30 | ISSM_TIER=ISSM_TIER(2:end-2);
|
|---|
| 31 |
|
|---|
| 32 | username=input('Username: (quoted string) ');
|
|---|
| 33 | key=input('Key: (quoted string) ');
|
|---|
| 34 |
|
|---|
| 35 | for i=1:numel(packages),
|
|---|
| 36 | [status,result]=system([ISSM_TIER '/externalpackages/ssh/pscp.exe -l "' username '" -pw "' key '" ' 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 |
|
|---|
| 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
|
|---|