Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Automated daily FTP download
Old 12-01-2003, 12:48 AM Automated daily FTP download
zgnilek's Avatar
Junior Talker

Posts: 4
Location: Melbourne, Australia
Trades: 0
Hi guys,

Need to find a way to automatically download a FTP file daily and save it to a specified directory. Any ideas? It would be good if I could also synchronize a folder on my server to reflect an FTP folder.

This is needed to upload an Excel file and display the information contained within that file on a site.

Thanks in advance.
zgnilek is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-01-2003, 02:58 PM
Experienced Talker

Posts: 31
Location: Redondo Beach, CA
Trades: 0
if on a unix/linux server you need to set a 'cron' job to run daily and execute a script. The script could be written in php if you have a cgi version or if not could use lynx or something similar to call a php script from the webserver or you could do it in perl.

If you are on a windows server it can be done, but I don't no how.

For instructions on setting a cron job try 'cron job' in a search engine and I'm sure there will be directions.
__________________
Myrealtypage - Real Estate Web Design
myrealtypage is offline
Reply With Quote
View Public Profile Visit myrealtypage's homepage!
 
Old 12-01-2003, 06:01 PM
zgnilek's Avatar
Junior Talker

Posts: 4
Location: Melbourne, Australia
Trades: 0
Yes, I knew that it was possible on Linux, however in this case I have to use Win 2K and code the application in ASP. ASP is necessary for a couple of components that the company already owns and want to use on the site.

There are third party software applications that will automate FTP downloads, however I would prefer to do this step entirely without the need to rely on third party components. Anyone got any ideas?
zgnilek is offline
Reply With Quote
View Public Profile
 
Old 12-01-2003, 06:01 PM
Chriz's Avatar
Novice Talker

Posts: 9
Location: Nowhere
Trades: 0
You can try using fopen() commands to save it to a directory on your site, and use a password protected folder to access it!
Chriz is offline
Reply With Quote
View Public Profile
 
Old 12-01-2003, 06:16 PM
zgnilek's Avatar
Junior Talker

Posts: 4
Location: Melbourne, Australia
Trades: 0
what is this fopen() you speak of?

Is it within ASP? There is a way to do FTP within ASP, isn't there? ****, need to do some more research on that code. Could you give an example and i will try to find out more as well.
zgnilek is offline
Reply With Quote
View Public Profile
 
Old 12-01-2003, 06:27 PM
zgnilek's Avatar
Junior Talker

Posts: 4
Location: Melbourne, Australia
Trades: 0
Ok guys, me think me found something:

This will FTP file from a remote server to a local directory, however i am sure that it can be tweaked to go the other way. I will give it a try and if i can't get it to work you will see another post, otherwise it works.


Dim objFSO, objTextFile, oScript, oScriptNet, oFileSys, oFile, strCMD, strTempFile, strCommandResult
Dim ftp_address, ftp_username, ftp_password, ftp_physical_path, ftp_files_to_put

' Edit these variables to match your specifications
ftp_address = "ftp.server.com"
ftp_username = "username"
ftp_password = "password"
ftp_remote_directory = "subdirectory" ' Leave blank if uploading to root directory
ftp_files_to_put = "file.txt"

On Error Resume Next
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Build our ftp-commands file
Set objTextFile = objFSO.CreateTextFile(Server.MapPath("test.ftp"))
objTextFile.WriteLine "lcd " & Server.MapPath(".")
objTextFile.WriteLine "open " & ftp_address
objTextFile.WriteLine ftp_username
objTextFile.WriteLine ftp_password

' Check to see if we need to issue a 'cd' command
If ftp_remote_directory <> "" Then
objTextFile.WriteLine "cd " & ftp_remote_directory
End If

objTextFile.WriteLine "prompt"

' If the file(s) is/are binary (i.e. .jpg, .mdb, etc..), uncomment the following line' objTextFile.WriteLine "binary"
' If there are multiple files to put, we need to use the command 'mput', instead of 'put'
If Instr(1, ftp_files_to_put, "*",1) Then
objTextFile.WriteLine "mput " & ftp_files_to_put
Else
objTextFile.WriteLine "put " & ftp_files_to_put
End If
objTextFile.WriteLine "bye"
objTextFile.Close
Set objTextFile = Nothing
' Use cmd.exe to run ftp.exe, parsing our newly created command file
strCMD = "ftp.exe -s:" & Server.MapPath("test.ftp")
strTempFile = "C:\" & oFileSys.GetTempName( )
' Pipe output from cmd.exe to a temporary file (Not :| Steve)
Call oScript.Run ("cmd.exe /c " & strCMD & " > " & strTempFile, 0, True)
Set oFile = oFileSys.OpenTextFile (strTempFile, 1, False, 0)

On Error Resume Next
' Grab output from temporary file
strCommandResult = Server.HTMLEncode( oFile.ReadAll )
oFile.Close
' Delete the temporary & ftp-command files
Call oFileSys.DeleteFile( strTempFile, True )
Call objFSO.DeleteFile( Server.MapPath("test.ftp"), True )
Set oFileSys = Nothing
Set objFSO = Nothing
' Print result of FTP session to screen
Response.Write( Replace( strCommandResult, vbCrLf, "<br>", 1, -1, 1) )
%>
zgnilek is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Automated daily FTP download
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18853 seconds with 12 queries