matlab: added timeout to FindFreeSSH

pull/1/head
Thorsten Liebig 2011-12-22 13:38:32 +01:00
parent 37922d3529
commit a704681aa4
1 changed files with 4 additions and 2 deletions

View File

@ -24,6 +24,9 @@ if (nargin<3)
command = 'ps -e | grep openEMS'; command = 'ps -e | grep openEMS';
end end
% 10 seconds ssh timeout
time_out = 10;
if (nargin<2) if (nargin<2)
wait_time = 600; wait_time = 600;
end end
@ -51,7 +54,7 @@ end
while 1 while 1
for n = 1:numel(host_list) for n = 1:numel(host_list)
host = host_list{n}; host = host_list{n};
[status, result] = unix(['ssh ' host ' ' command]); [status, result] = unix(['ssh -o ConnectTimeout=' num2str(time_out) ' ' host ' ''' command '''']);
if (isempty(result) && status==1) if (isempty(result) && status==1)
disp(['FindFreeSSH:: found a free host: ' host ]); disp(['FindFreeSSH:: found a free host: ' host ]);
@ -61,7 +64,6 @@ while 1
else else
disp(['FindFreeSSH:: shh connection to ' host ' failed ... ' ]); disp(['FindFreeSSH:: shh connection to ' host ' failed ... ' ]);
end end
end end
host = ''; host = '';