-
Notifications
You must be signed in to change notification settings - Fork 0
/
lscp.m
27 lines (21 loc) · 785 Bytes
/
lscp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function lscp(from,to,ls_options,scp_options)
% first ls to check existence of file(s), then scp them if they do.
if nargin<4 , scp_options = '' ; end
if nargin<3 , ls_options = '' ; end
from = regexp(from,' ','split') ;
for i=1:length(from)
[status,stdout] = unix( sprintf('ls %s %s',ls_options,from{i}) ) ;
if ~status
if ~strcmp(stdout,'ls: ') % file exists
these = regexp(stdout,'\s','split') ;
for j=1:length(these)
if ~isempty(these{j})
command = sprintf('scp %s %30s \t %s',scp_options,these{j},to) ;
fprintf(sprintf('%s\n',command))
xinu( command ) ;
end
end
end
end
end
end