locked
Automactically dump files onto FTP RRS feed

  • Question

  • User647458646 posted

    Dear all, 

    I am writing to seek guidance, how to develop an application which can automactically extract file from the server and dump it on client ftp.

    I have worked out the logic:

    get data from the server, convert data into csv excel sheet and upload onto ftp client.  

    I would like to implement the following logic above using automactic scheduler, if possible. 

    Any help or advice into how would I go about compiling this project, would be very much appreciated.

    Many thanks

    Monday, October 14, 2013 11:27 AM

Answers

  • User1508394307 posted

    I think it all can be done either with standard tools, e.g. using sqlcmd and ftp command line utilities, or developing a console application. In both case you can schedule it using Windows Scheduler.

    Example of bat file of sqlcmd+ftp

    sqlcmd -q "select col1,col2,col3 from table" -oc:\myfile.csv -h-1 -s","
    echo user MyUserName> ftpcmd.dat
    echo MyPassword>> ftpcmd.dat
    echo bin>> ftpcmd.dat
    echo put c:\myfile.csv>> ftpcmd.dat
    echo quit>> ftpcmd.dat
    ftp -n -s:ftpcmd.dat SERVERNAME.COM
    del ftpcmd.dat

    If you choose a "non-ASP way" please continue the thread in an appropriate forum.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 14, 2013 11:38 AM

All replies

  • User753101303 posted

    Hi,

    What is the source server ? A web server, a file server , another FTP Server ? You will be able to send files using http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx

    You could use http://windows.microsoft.com/en-au/windows7/schedule-a-task to schedule your code as needed.

    "upload onto ftp client" is a bit weird (when you upload a file this is always from a client to a server). A server can't send files to a client if the client doesn't ask for them exactly as a web server can't send a page to a browser if the browser doesn't ask for it.

    If you still need help try to narrow down a bit your question so that we can focus on the particular points on which you need help (for now I assumed it was about sending files using ftp and how to best schedule this app).

     

    Monday, October 14, 2013 11:33 AM
  • User1508394307 posted

    I think it all can be done either with standard tools, e.g. using sqlcmd and ftp command line utilities, or developing a console application. In both case you can schedule it using Windows Scheduler.

    Example of bat file of sqlcmd+ftp

    sqlcmd -q "select col1,col2,col3 from table" -oc:\myfile.csv -h-1 -s","
    echo user MyUserName> ftpcmd.dat
    echo MyPassword>> ftpcmd.dat
    echo bin>> ftpcmd.dat
    echo put c:\myfile.csv>> ftpcmd.dat
    echo quit>> ftpcmd.dat
    ftp -n -s:ftpcmd.dat SERVERNAME.COM
    del ftpcmd.dat

    If you choose a "non-ASP way" please continue the thread in an appropriate forum.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 14, 2013 11:38 AM
  • User647458646 posted

    Dear smirnov

    Thank you so much for your response.  Can this task be completed if the machine is online and offline?

    Many thanks

    Monday, October 14, 2013 11:41 AM
  • User1508394307 posted

    Export from the database server can be done when database server is available from the machine where you call that script.
    Sending a file to remote ftp server is required an internet connection. 

    Monday, October 14, 2013 12:30 PM