PRO cp_fns, list, fdir, tdir, mv=mv, mach=mach, acc_sw=acc_sw, $
            qdebug=qdebug
;   ----------------------------------------------------------
    if (strpos(fdir, '_', 0) ne -1) then begin  ;valid online dir
      from_path = wk_online(fdir)       ;path to on-line dir.   
    endif else begin
      print, 'Error: invalid input directory name: ', fdir
      return
    endelse

    tpath = concat_dir(tdir, '.')

        copy = 'cp '
    IF keyword_set(mv) then copy = 'mv '

;       slf - verify integrity of source (mag) and destination files (mo)
        sfiles=file_list(from_path,strtrim(list,2))
        dfiles=file_list(tpath,strtrim(list,2))

        message,/info,"Checking integrity of input files...
        ys_file_check,sfiles, badfiles, all=all, status=status

        if not all then begin
           mess="Problem with one or more input files, aborting..."
           message,/info,mess
           prstr, badfiles
           mail,/self,[mess,'',badfiles],subj="mk_mo - bad soure files"
           return
        endif

    IF KEYWORD_SET(mach) THEN BEGIN     ;do copy via "rsh"
      for i=0, n_elements(list)-1 do begin
        cp_cmd = copy+from_path+strtrim(list(i),2)+' '+tpath
        print, 'Copying Files on '+strtrim(mach,2)+': ', $
            from_path+strtrim(list(i),2)
        if i eq 0 then print, 'cp_cmd(0): ', cp_cmd     
            if (not keyword_set(qdebug)) then $
           rsh,mach,cp_cmd,user='mocreate',/null
            file_delete,concat_dir(tdir, 'cba*')
      endfor
    ENDIF ELSE BEGIN
      for i=0, n_elements(list)-1 do begin
        cp_cmd = copy+from_path+strtrim(list(i),2)+' '+tpath

        print, 'Copying Files: ', from_path+strtrim(list(i),2)
        if i eq 0 then print, 'cp_cmd(0): ', cp_cmd
        if (not keyword_set(qdebug)) then spawn, cp_cmd
      endfor
    ENDELSE

        message,/info,"Checking integrity of destination files...
        ys_file_check,dfiles, badfiles, all=all, status=status
        if not all then begin
           mess="Problem with one or more files during mo write"
           message,/info,mess
           prstr,badfiles
           mail,[mess,'',badfiles],/self,subj="mk_mo - bad mo creation"
        endif

        return
    END