pro ftp_getput, file, node, user,passwd, remote_dir=remote_dir, $ local_dir=local_dir, put=put, ascii=ascii, anonymous=anonymous, $ auto_login = auto_login, message=message, status=status ;+ ; NAME: FTP_GETPUT ; PURPOSE: Get a file from or put it to a remote machine using FTP ; CALLING SEQUENCE: ; FTP_GETPUT, FILE, NODE, USER, PASSWD ; INPUT: ; FILE the file name to be gotten or put ; NODE the node of the remote machine ; USER user id ; PASSWD password. USER and PASSWD can be omitted if either ; ANONYMOUS or AUTO_LOGIN keyword is set. ; KEYWORDS: ; REMOTE_DIR the remote directory (default is the home directory) ; LOCAL_DIR the local directory (deafult id the current directory) ; PUT if set, the file is put (default id to get it) ; ASCII if set, the ASCII mode is chosen (default is BINARY) ; ANONYMOUS if set, anonymous FTP is tried. ; AUTO_LOGIN if set, auto-login FTP is tried. This works ; only UNIX-campatible machines and the file $HOME/.netrc ; should exist and contain the proper infomation. ; STATUS is set to 1 (success) or 0 (failure). Valid only for GET ; ; HISTORY: ; 1998 November Created Jongchul Chae ;- cd, current = cdir status=0 if keyword_set(auto_login) and !version.os_family eq 'vms' then begin tmp = widget_message(/error, $ 'Sorry! Auto-login ftp is not defined in VMS machines.') return end com = 'open '+node if keyword_set(anonymous) then com = [com, 'user anonymous anonymous'] $ else if not keyword_set(auto_login) then com = [com, 'user '+user+ ' '+passwd] if keyword_set(ascii) then com =[com, 'ascii'] $ else com =[com, 'binary'] if n_elements(remote_dir) eq 1 then com=[com, 'cd '+remote_dir] if n_elements(local_dir) eq 0 then local_dir=cdir com = [com, 'lcd '+local_dir] if keyword_set(put) then $ for ff=0, n_elements(file)-1 do com = [com, 'put '+file(ff)] $ else for ff=0, n_elements(file)-1 do com = [com, 'get '+file] com = [com, 'lcd '+cdir] com = [com, 'bye'] if !version.os_family eq 'vms' then com = [com, 'exit'] home = getenv('HOME') fcom = concat_dir(home, 'sumer_ftp.com') openw, unit, fcom, /get_lun for k=0, n_elements(com)-1 do printf, unit, com(k) free_lun, unit if !version.os_family eq 'unix' then $ if keyword_set(auto_login) then spawn, 'ftp < '+ fcom,message $ else spawn, 'ftp -n < '+fcom, message if !version.os_family eq 'vms' then spawn, 'ftp /take_file='+fcom, message file_delete, fcom end