function []=doit2(nwait,tmr);
% doit.m - does three steps:
% - scp adcp raw data to local machine
% - run 'runos'
% - run plot_os
% - set timer method 0 - MATLAB 1 - Perl

while(1)
  %tic
  t0=clock
  !get_LTA_data

  cd ../adcp/oc415
  !runos
  cd ../../adcp_nb
  plot_os
  figure(1)
  drawnow
  
 if nwait < 0
   break
 else
   %tt=toc; % get elapsed time from 'tic'
   tt=etime(clock,t0)
   iwait=nwait*60-tt % iwait is in seconds
   disp(['waiting ',num2str(iwait/60),' minutes ....'])
   %pause(iwait) % wait iwait seconds between plots
   if tmr == 0
     pause(iwait)
   else
     disp(['!wait.pl ', int2str(ceil(iwait))])
     eval(['!wait.pl ', int2str(ceil(iwait))])
   end
 end
end
