;+ ; NAME: ; forecast_ftp ; PURPOSE: ; Uses ftp to copy files to cassfos02 ; CATEGORY: ; WWW ; CALLING SEQUENCE: PRO forecast_ftp, kind, bin_file, asc_file, silent=silent ; INPUTS: ; kind scalar; type: string ; 'slow' or 'fast' ; CALLS: ; SetFileSpec, GetFileSpec, do_file, boost ; INCLUDE: @compile_opt.pro ; On error, return to caller ; PROCEDURE: ; Note that automatic ftp to cassfos02 needs to be set up with the ; appropriate entry into .netrc (ftp needs a username and password ; to access cassfos02) ; MODIFICATION HISTORY: ; APR-2001, Paul Hick (UCSD/CASS) ; AUG-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Removed 'cd' ftp-commands to remote directory, and switched to 'put' ; commands for individual images instead of 'mput' for the whole bunch. ;- InitVar, silent, 0 ; Receiving host and directory ftp_hosts = ['cass']; ,'cassfos02' ] ftp_dirs = ['/var/www/html/solar/','/u8/WWW/solar/']+'forecast/'+kind+'/current' ftp_scps = [ 1, 0] ftp_users = ['solar',''] FOR ihost=0,n_elements(ftp_hosts)-1 DO BEGIN ftp_host = ftp_hosts[ihost] ftp_dir = ftp_dirs [ihost] ftp_scp = ftp_scps [ihost] ftp_user = ftp_users[ihost] destroyvar, ftp_cmd CASE ftp_scp OF 0: BEGIN FOR ifile=0,n_elements(bin_file)-1 DO BEGIN IF ifile EQ 0 THEN boost, ftp_cmd, 'binary' tmp_file = file_search(bin_file[ifile], count=count) IF count GT 0 THEN BEGIN SetFileSpec, tmp_file boost, ftp_cmd, 'put '+tmp_file+' '+filepath(root=ftp_dir,GetFileSpec(from='name')) ENDIF ENDFOR FOR ifile=0,n_elements(asc_file)-1 DO BEGIN IF ifile EQ 0 THEN boost, ftp_cmd, 'ascii' tmp_file = file_search(asc_file[ifile], count=count) IF count GT 0 THEN BEGIN SetFileSpec, tmp_file boost, ftp_cmd, 'put '+tmp_file+' '+filepath(root=ftp_dir,GetFileSpec(from='name')) ENDIF ENDFOR boost, ftp_cmd, 'quit' tmp_file = filepath(root=getenv('TUB'), ftp_host+'.ftp') openw, /get_lun, iu, tmp_file FOR i=0,n_elements(ftp_cmd)-1 DO printf, iu, ftp_cmd[i] free_lun, iu cmd = 'cat '+tmp_file IF silent LE 1 THEN BEGIN print message, /info, 'transfer to '+ftp_host+'.ucsd.edu' IF silent LE 0 THEN spawn, cmd ENDIF cmd = cmd+' | ftp -i '+ftp_host+'.ucsd.edu' END 1: BEGIN boost, ftp_cmd, '#! /bin/bash' FOR ifile=0,n_elements(bin_file)-1 DO BEGIN tmp_file = file_search(bin_file[ifile], count=count) IF count GT 0 THEN BEGIN SetFileSpec, tmp_file boost, ftp_cmd, 'scp -q '+tmp_file+' '+ftp_user+'@'+ftp_host+'.ucsd.edu:'+filepath(root=ftp_dir,GetFileSpec(from='name')) ENDIF ENDFOR FOR ifile=0,n_elements(asc_file)-1 DO BEGIN tmp_file = file_search(asc_file[ifile], count=count) IF count GT 0 THEN BEGIN SetFileSpec, tmp_file boost, ftp_cmd, 'scp -q '+tmp_file+' '+ftp_user+'@'+ftp_host+'.ucsd.edu:'+filepath(root=ftp_dir,GetFileSpec(from='name')) ENDIF ENDFOR tmp_file = filepath(root=getenv('TUB'), ftp_host+'.scp') openw, /get_lun, iu, tmp_file FOR i=0,n_elements(ftp_cmd)-1 DO printf, iu, ftp_cmd[i] free_lun, iu cmd = 'cat '+tmp_file IF silent LE 1 THEN BEGIN print message, /info, 'transfer to '+ftp_host+'.ucsd.edu' IF silent LE 0 THEN spawn, cmd ENDIF cmd = cmd+' | bash' END ENDCASE IF silent LE 0 THEN print, cmd spawn, cmd tmp = do_file(/delete, tmp_file, /silent) ENDFOR IF silent LE 1 THEN BEGIN print print ENDIF RETURN & END