![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, I think I'm going to ask the stupidest question there is but, I need to download a file daily from a website, it will always be the same filename, just different content. Now I can schedule a job to run on my server (SQL Server 2000) but what script do I use to tell the pc that it's gotta download an excel file to directory? I cannot use FTP unfortunately, then it would be easier, I can only download this file via HTTP I tried copy Http://www.server.co.za/file.xls c:\file\ But it tells me invalid device.... Doh... Could someone plz help me Thanks, R |
#3
| |||
| |||
|
|
Use some VBScript in a DTS package or a job. Something like this should do http://groups.google.co.uk/groups?hl...G P12.phx.gbl -- Darren Green http://www.sqldts.com "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct2ts5$d0p$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi all, I think I'm going to ask the stupidest question there is but, I need to download a file daily from a website, it will always be the same filename, just different content. Now I can schedule a job to run on my server (SQL Server 2000) but what script do I use to tell the pc that it's gotta download an excel file to directory? I cannot use FTP unfortunately, then it would be easier, I can only download this file via HTTP I tried copy Http://www.server.co.za/file.xls c:\file\ But it tells me invalid device.... Doh... Could someone plz help me Thanks, R |
#4
| |||
| |||
|
|
Hi Darren, Thanks that works! ![]() "Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in message news:e6$TpxhAFHA.2112 (AT) TK2MSFTNGP14 (DOT) phx.gbl... Use some VBScript in a DTS package or a job. Something like this should do http://groups.google.co.uk/groups?hl...G P12.phx.gbl -- Darren Green http://www.sqldts.com "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct2ts5$d0p$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi all, I think I'm going to ask the stupidest question there is but, I need to download a file daily from a website, it will always be the same filename, just different content. Now I can schedule a job to run on my server (SQL Server 2000) but what script do I use to tell the pc that it's gotta download an excel file to directory? I cannot use FTP unfortunately, then it would be easier, I can only download this file via HTTP I tried copy Http://www.server.co.za/file.xls c:\file\ But it tells me invalid device.... Doh... Could someone plz help me Thanks, R |
#5
| |||
| |||
|
|
Ok this is what my script looks like: dim mInternet dim mFile dim mFiletxt Set mInternet= CreateObject("Microsoft.XMLHTTP" ) mInternet.open "GET" , "http://www.server.co.za/mserv.xls", false mInternet.send mFiletxt= mInternet.Responsetext set mInternet = nothing set mFileObj = createObject("scripting.FilesystemObject") set mfile = mfileObj.createtextfile("c:\mserv.xls") mfile.write mfiletxt mfile.close set mfile = nothing set mfileobj = nothing The error that I get when running it: Error: Invalid procedure call or argument Code: 800A0005 Line 13, Char 5 Help... Thanks alot "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct303j$gsn$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi Darren, Thanks that works! ![]() "Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in message news:e6$TpxhAFHA.2112 (AT) TK2MSFTNGP14 (DOT) phx.gbl... Use some VBScript in a DTS package or a job. Something like this should do http://groups.google.co.uk/groups?hl...G P12.phx.gbl -- Darren Green http://www.sqldts.com "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct2ts5$d0p$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi all, I think I'm going to ask the stupidest question there is but, I need to download a file daily from a website, it will always be the same filename, just different content. Now I can schedule a job to run on my server (SQL Server 2000) but what script do I use to tell the pc that it's gotta download an excel file to directory? I cannot use FTP unfortunately, then it would be easier, I can only download this file via HTTP I tried copy Http://www.server.co.za/file.xls c:\file\ But it tells me invalid device.... Doh... Could someone plz help me Thanks, R |
#6
| |||
| |||
|
|
How are you running this, and which line is 13? I assume this will run unattended at some point, so it is bettrer to use "MSXML2.ServerXMLHTTP.4.0" instead of "Microsoft.XMLHTTP". -- Darren Green http://www.sqldts.com Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct318c$iek$1 (AT) ctb-nnrp2 (DOT) saix.net... Ok this is what my script looks like: dim mInternet dim mFile dim mFiletxt Set mInternet= CreateObject("Microsoft.XMLHTTP" ) mInternet.open "GET" , "http://www.server.co.za/mserv.xls", false mInternet.send mFiletxt= mInternet.Responsetext set mInternet = nothing set mFileObj = createObject("scripting.FilesystemObject") set mfile = mfileObj.createtextfile("c:\mserv.xls") mfile.write mfiletxt mfile.close set mfile = nothing set mfileobj = nothing The error that I get when running it: Error: Invalid procedure call or argument Code: 800A0005 Line 13, Char 5 Help... Thanks alot "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct303j$gsn$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi Darren, Thanks that works! ![]() "Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in message news:e6$TpxhAFHA.2112 (AT) TK2MSFTNGP14 (DOT) phx.gbl... Use some VBScript in a DTS package or a job. Something like this should do http://groups.google.co.uk/groups?hl...G P12.phx.gbl -- Darren Green http://www.sqldts.com "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct2ts5$d0p$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi all, I think I'm going to ask the stupidest question there is but, I need to download a file daily from a website, it will always be the same filename, just different content. Now I can schedule a job to run on my server (SQL Server 2000) but what script do I use to tell the pc that it's gotta download an excel file to directory? I cannot use FTP unfortunately, then it would be easier, I can only download this file via HTTP I tried copy Http://www.server.co.za/file.xls c:\file\ But it tells me invalid device.... Doh... Could someone plz help me Thanks, R |
#7
| |||
| |||
|
|
Hi Darren, Well, I am testing by just double clicking in windows, but when the script does what I want it to, it'll be running in a DTS task on sql server 2000. My script is: dim mInternet dim mFile dim mFiletxt Set mInternet= CreateObject("Microsoft.XMLHTTP" ) mInternet.open "GET" , "http://www.oilwatch.co.za/mserv.xls", false mInternet.send mFiletxt= mInternet.Responsetext set mInternet = nothing set mFileObj = createObject("scripting.FilesystemObject") set mfile = mfileObj.createtextfile("c:\mserv.txt") mfile.write mfiletxt mfile.close set mfile = nothing set mfileobj = nothing And line 13 will be at: mfile.write mfiletxt "Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in message news:OMLJ6PiAFHA.2572 (AT) tk2msftngp13 (DOT) phx.gbl... How are you running this, and which line is 13? I assume this will run unattended at some point, so it is bettrer to use "MSXML2.ServerXMLHTTP.4.0" instead of "Microsoft.XMLHTTP". -- Darren Green http://www.sqldts.com Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct318c$iek$1 (AT) ctb-nnrp2 (DOT) saix.net... Ok this is what my script looks like: dim mInternet dim mFile dim mFiletxt Set mInternet= CreateObject("Microsoft.XMLHTTP" ) mInternet.open "GET" , "http://www.server.co.za/mserv.xls", false mInternet.send mFiletxt= mInternet.Responsetext set mInternet = nothing set mFileObj = createObject("scripting.FilesystemObject") set mfile = mfileObj.createtextfile("c:\mserv.xls") mfile.write mfiletxt mfile.close set mfile = nothing set mfileobj = nothing The error that I get when running it: Error: Invalid procedure call or argument Code: 800A0005 Line 13, Char 5 Help... Thanks alot "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct303j$gsn$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi Darren, Thanks that works! ![]() "Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in message news:e6$TpxhAFHA.2112 (AT) TK2MSFTNGP14 (DOT) phx.gbl... Use some VBScript in a DTS package or a job. Something like this should do http://groups.google.co.uk/groups?hl...G P12.phx.gbl -- Darren Green http://www.sqldts.com "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct2ts5$d0p$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi all, I think I'm going to ask the stupidest question there is but, I need to download a file daily from a website, it will always be the same filename, just different content. Now I can schedule a job to run on my server (SQL Server 2000) but what script do I use to tell the pc that it's gotta download an excel file to directory? I cannot use FTP unfortunately, then it would be easier, I can only download this file via HTTP I tried copy Http://www.server.co.za/file.xls c:\file\ But it tells me invalid device.... Doh... Could someone plz help me Thanks, R |
#8
| |||
| |||
|
|
Something to do with data types, probably a byte array or something. Safest to use a stream - Option Explicit Function Main() Dim xmlHttp Dim response Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.Open "GET" , "http://localhost/test.xls", False xmlhttp.Send response = xmlHttp.ResponseBody Set xmlHttp = Nothing Dim oADOStream Set oADOStream = CreateObject("ADODB.Stream") oADOStream.Type = 1 '(binary) oADOStream.Mode = 3 '(read / write) oADOStream.Open oADOStream.Write response oADOStream.SaveToFile "C:\Test.xls", 2 oADOStream.Close Set oADOStream = Nothing Main = DTSTaskExecResult_Success End Function -- Darren Green http://www.sqldts.com http://www.sqlis.com "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct32ol$l04$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi Darren, Well, I am testing by just double clicking in windows, but when the script does what I want it to, it'll be running in a DTS task on sql server 2000. My script is: dim mInternet dim mFile dim mFiletxt Set mInternet= CreateObject("Microsoft.XMLHTTP" ) mInternet.open "GET" , "http://www.oilwatch.co.za/mserv.xls", false mInternet.send mFiletxt= mInternet.Responsetext set mInternet = nothing set mFileObj = createObject("scripting.FilesystemObject") set mfile = mfileObj.createtextfile("c:\mserv.txt") mfile.write mfiletxt mfile.close set mfile = nothing set mfileobj = nothing And line 13 will be at: mfile.write mfiletxt "Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in message news:OMLJ6PiAFHA.2572 (AT) tk2msftngp13 (DOT) phx.gbl... How are you running this, and which line is 13? I assume this will run unattended at some point, so it is bettrer to use "MSXML2.ServerXMLHTTP.4.0" instead of "Microsoft.XMLHTTP". -- Darren Green http://www.sqldts.com Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct318c$iek$1 (AT) ctb-nnrp2 (DOT) saix.net... Ok this is what my script looks like: dim mInternet dim mFile dim mFiletxt Set mInternet= CreateObject("Microsoft.XMLHTTP" ) mInternet.open "GET" , "http://www.server.co.za/mserv.xls", false mInternet.send mFiletxt= mInternet.Responsetext set mInternet = nothing set mFileObj = createObject("scripting.FilesystemObject") set mfile = mfileObj.createtextfile("c:\mserv.xls") mfile.write mfiletxt mfile.close set mfile = nothing set mfileobj = nothing The error that I get when running it: Error: Invalid procedure call or argument Code: 800A0005 Line 13, Char 5 Help... Thanks alot "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct303j$gsn$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi Darren, Thanks that works! ![]() "Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in message news:e6$TpxhAFHA.2112 (AT) TK2MSFTNGP14 (DOT) phx.gbl... Use some VBScript in a DTS package or a job. Something like this should do http://groups.google.co.uk/groups?hl...G P12.phx.gbl -- Darren Green http://www.sqldts.com "Rudi Groenewald" <noone (AT) paflof (DOT) com> wrote in message news:ct2ts5$d0p$1 (AT) ctb-nnrp2 (DOT) saix.net... Hi all, I think I'm going to ask the stupidest question there is but, I need to download a file daily from a website, it will always be the same filename, just different content. Now I can schedule a job to run on my server (SQL Server 2000) but what script do I use to tell the pc that it's gotta download an excel file to directory? I cannot use FTP unfortunately, then it would be easier, I can only download this file via HTTP I tried copy Http://www.server.co.za/file.xls c:\file\ But it tells me invalid device.... Doh... Could someone plz help me Thanks, R |
#9
| |||
| |||
|
#10
| |||
| |||
|
|
C# Code sample ------------------------------ static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: downloadfile [url] [localfile]"); return; } try { System.Net.WebClient client = new WebClient(); client.DownloadFile(args[0], args[1]); } catch(Exception e) { Console.WriteLine(e.ToString()); }; } http://www.csharphelp.com/archives2/archive454.html DishanF *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
![]() |
| Thread Tools | |
| Display Modes | |
| |