|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
How do you schedule a server to download a file hourly?
Probably an easy solution, but I just don't know it.
I need some way to automatically download an XML file from a web site down to my server (Win2k3-IIS) so I can write a script to pull data from the local file and post it. I want to get an update remote file every hour and save it locally. What are my options? Last edited by diffenc : May 7th, 2004 at 09:10 AM. |
|
#2
|
|||
|
|||
|
You might be able to do something with the server's task scheduler.
__________________
====== Doug G ====== "Hide, hide witch! The good folk come to burn thee. Their keen enjoyment hid behind their gothic mask of duty." -Mark Clifton |
|
#3
|
|||
|
|||
|
i'd create an exe to do the download then run it with the taks scheduler
Something like this should work Public Class saveAs Public Function saveTheFile() Dim objWebClient As New WebClient Dim commandLineArgs As String() Dim rUrl As String commandLineArgs = System.Environment.GetCommandLineArgs() If commandLineArgs.Length > 1 Then rUrl = commandLineArgs(1) Else rUrl = "http://blah.com/xml.xml" End If Dim aRequestedHTML() As Byte aRequestedHTML = objWebClient.DownloadData(rUrl) Dim objUTF8 As New UTF8Encoding Dim strRequestedHTML As String strRequestedHTML = objUTF8.GetString(aRequestedHTML) writeTofile(strRequestedHTML.ToString) End Function Private Sub writeTofile(ByVal sHtml As String) Dim month As Integer = DateTime.Now.Month Dim day As Integer = DateTime.Now.Day Dim year As Integer = DateTime.Now.Year Dim commandLineArgs As String() Dim pathRoot As String commandLineArgs = System.Environment.GetCommandLineArgs() If commandLineArgs.Length > 2 Then pathRoot = commandLineArgs(2) 'Console.WriteLine(pathRoot) Else pathRoot = "C:\" End If Dim filePath As String = pathRoot & month & "-" & day & "-" & year & ".xls" Try If sHtml.Length > 1 Then Dim oFileStream As FileStream = New FileStream(filePath, FileMode.Append, FileAccess.Write) Dim oStreamWriter As StreamWriter = New StreamWriter(oFileStream) oStreamWriter.Write(sHtml) oStreamWriter.Flush() oStreamWriter.Close() End If Catch ex As Exception 'igonore End Try End Sub End Class |
|
#4
|
|||
|
|||
|
Use some kind of program and schedule it in the task scheduler. You could write the program in VB, VBScript, or something.
|
![]() |
| Viewing: Dev Shed Forums > System Administration > IIS > How do you schedule a server to download a file houry? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|