dbTalk Databases Forums  

Download a file using HTTP

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Download a file using HTTP in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rudi Groenewald
 
Posts: n/a

Default Download a file using HTTP - 01-24-2005 , 07:39 AM






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




Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Download a file using HTTP - 01-24-2005 , 07:54 AM






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

Quote:
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






Reply With Quote
  #3  
Old   
Rudi Groenewald
 
Posts: n/a

Default Re: Download a file using HTTP - 01-24-2005 , 08:17 AM



Hi Darren,

Thanks that works!


"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
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








Reply With Quote
  #4  
Old   
Rudi Groenewald
 
Posts: n/a

Default Re: Download a file using HTTP - 01-24-2005 , 08:37 AM



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

Quote:
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










Reply With Quote
  #5  
Old   
Darren Green
 
Posts: n/a

Default Re: Download a file using HTTP - 01-24-2005 , 08:48 AM



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

Quote:
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












Reply With Quote
  #6  
Old   
Rudi Groenewald
 
Posts: n/a

Default Re: Download a file using HTTP - 01-24-2005 , 09:03 AM



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

Quote:
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














Reply With Quote
  #7  
Old   
Darren Green
 
Posts: n/a

Default Re: Download a file using HTTP - 01-25-2005 , 11:33 AM



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

Quote:
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
















Reply With Quote
  #8  
Old   
Rudi Groenewald
 
Posts: n/a

Default Re: Download a file using HTTP - 01-26-2005 , 02:35 AM



Hi Darren,

When I run the script, notihng happens. Am I doing something wrong?

Thanks

R


"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
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


















Reply With Quote
  #9  
Old   
DishanF
 
Posts: n/a

Default Re: Download a file using HTTP - 01-26-2005 , 03:18 AM



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!

Reply With Quote
  #10  
Old   
Rudi Groenewald
 
Posts: n/a

Default Re: Download a file using HTTP - 01-26-2005 , 04:28 AM



Hi, Thanks for the help but, I get the error...

Expected Statement,

Line 1, char 1


"DishanF" <d700693 (AT) hotmail (DOT) com> wrote

Quote:
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!



Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.