Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: automated ftp
Logs into a server, copies all the files in a ftp dir to a target dir, then renames the files to a 2nd destination dir
;---------------------- ; sample ftp push script ; by Jay Alverson ; ;---------------------- ;---------------------- ; get to the correct fileshare ; I: = \\server\ftp_share ; ;---------------------- dirchange("I:\file dir") phsflist = fileitemize("*.*") parsedata(phsflist) files_2_copy = param0 ;---------------------- ; open the log file for writing ; ; ;---------------------- loghandle = fileopen("I:\Log\FTPLog.txt","APPEND") ;---------------------- ; initiate the FTP session ; ; ;---------------------- a=TimeYmdHms( ) AddExtender("WWWSK34I.DLL") ; read in the host info, user_id, password from a private INI file... host=IniReadPvt("CHAMP EDI", "HOST", "", "C:\BIN\FTP.INI") userid=IniReadPvt("CHAMP EDI", "U", "", "C:\BIN\FTP.INI") pswd=IniReadPvt("CHAMP EDI", "P", "", "C:\BIN\FTP.INI") acct="" hSession=ftpOpen(host,userid,pswd,acct,3) ;---------------------- ; check for error on no connection ; ; ;---------------------- if !IsNumber(hSession) Message("FTP Open Error",hSession) errorline = strcat(timedate(),",","Error Opening FTP Session") filewrite(loghandle, errorline) exit endif ;---------------------- ; once we're connected to the FTP box ; change directories to the place our outbound files reside in, ; then copy the files via ascii, 1 by 1 ;---------------------- ftpchdir(hsession,"inbox") for x = 1 to files_2_copy phsfile = itemextract(x,phsflist,@tab) cpqfile = phsfile rs=ftpPut(hSession, phsfile, cpqfile, "A") timeput = Timedate( ) logline = strcat(timeput,",",phsfile,",","SUCCESS") filewrite(loghandle, logline) next ; rename the files on the remote FTP box... for x = 1 to files_2_copy phsfile = itemextract(x,phsflist,@tab) cpqfile = strcat("P",phsfile) rs=ftpRename(hSession, phsfile, cpqfile) timeput = Timedate( ) logline = strcat(timeput,",",cpqfile,",","RENAME") filewrite(loghandle, logline) next fileclose(loghandle) for x = 1 to files_2_copy phsfile = itemextract(x,phsflist,@tab) cpqfile = strcat("I:\Log\","O",phsfile) filemove(phsfile,cpqfile,@false) next ;b=TimeYmdHms( ) ftpClose(hSession) Message("FTP","End of Job")
Article ID: W14209
Filename: Sample FTP Push Script.txt
File Created: 2001:03:01:15:10:26
Last Updated: 2001:03:01:15:10:26