option explicit'this program gets the log files from an FTP Server
dim build_filename' the name of the file that will need to run from the scheduler
dim build_directory' the location it will be built
dim login_filename' the name of the file with the login info
dim ftp_file' the file we want to get
dim dest_loc' final location of the file that will be ftp'd
dim ftp_site' location to ftp to
dim ftp_directory' ftp directory
dim ftp_username' login username
dim ftp_password' login password
dim temp_str, temp_strII
build_filename= "get_files.bat"
build_directory= "c:/logs/"
login_filename= "get_yourdomain.txt"
ftp_file= ""
dest_loc= "c:/logs/"
ftp_site= "" ' put ftp site here
ftp_directory= ""' put ftp logs here
ftp_username= ""' put username here
ftp_password= ""'put password here
temp_str= ""
temp_strII= ""
call write_blank(build_directory, login_filename)
call write_send(build_directory, login_filename, ftp_username)
call write_send(build_directory, login_filename, ftp_password)
call write_send(build_directory, login_filename, "cd " & ftp_directory)
call write_send(build_directory, login_filename, "get " & log_filename(ftp_file))
call write_blank(build_directory, build_filename)
call write_send(build_directory, build_filename, "cd " & dest_loc)
call write_send(build_directory, build_filename, "ftp -i -s:" & build_directory & login_filename & " " & ftp_site)
call write_send(build_directory, build_filename, "bye " )
function write_send(loc, file, txt)
Dim ofs
Dim objtextstream
Set ofs = CreateObject("Scripting.FileSystemObject")
Set objtextstream = ofs.openTextFile(loc & file,8, True)
objtextstream.writeline txt
objtextstream.Close
Set objtextstream = Nothing
Set ofs = Nothing
end function
function write_blank(loc, file)
dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(loc & file, True)
MyFile.Close
end function
function log_filename(ftp_file)
'put the prefix for your files in the first set of quotes in the next line
ftp_file = "" & left(monthname(month(now()-1)), 3)
if day(now()-1) < 10 then ftp_file = ftp_file & "0"
ftp_file = ftp_file & day(now()-1) & "_" & year(now())
log_filename = ftp_file
end function