Re: Anything to help download files ?
- From: Michael Schlenker <schlenk@xxxxxxxxxxxxxxxx>
- Date: Wed, 03 Jan 2007 20:55:08 +0100
Dave (from the UK) schrieb:
I have an application that will download a number of zip files from the
web. All file names are similar (just a number changes), its easy to
automate.
At the minute I have a very poor way of doing this in TCL.
catch {exec /bin/sh -c "cpdown $::tools::firstWeek $::tools::maxweek &" }
it basically calls a UNIX shell script ('cpdown') to do all the work.
FirstWeek' and 'maxweek' will be integers
so the UNIX shell might sell
cpdown 400 600
and so it will download the 201 files.
There are obvious problems with this.
1) I've got no idea of progress. Whether one file has been download, or
199 I have no idea. Currently any errors from the tool I'm using to do
the downloads (wget) are ignored.
2) No error handling mechanism.
3) While this is happening, the rest of the Tcl program hangs until the
download has finished. I thought having the ampersand on the shell
command would have meant this happened in the background, but it does
not appear to do so.
4) The above only works on UNIX, although I've seen a similar example
somewhere which works on Windoze.
So I'm looking for a better solution.
Would you make a loop in Tcl, and use that to call the program to
download the files? I've never used a loop in Tcl, but I assume it would
support them.
Is there anything in Tcl to download files via HTTP, or is calling an
external program 'wget' a pretty sensible way?
It may be sensible, but there is a pretty ok HTTP 1.0 client package
included with nearly any Tcl installation you'll find.
Look at http://wiki.tcl.tk/http for some ideas and examples.
Michael
.
- References:
- Anything to help download files ?
- From: Dave (from the UK)
- Anything to help download files ?
- Prev by Date: Re: Best way of error handling in TCL
- Next by Date: Re: to enter data into EXCEL ***
- Previous by thread: Re: Anything to help download files ?
- Next by thread: Re: Anything to help download files ?
- Index(es):