Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Problems with copying a file from the Internet.

From   Christopher Baum <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Problems with copying a file from the Internet.
Date   Mon, 12 Sep 2011 15:52:53 -0400

Guo replied to Ulrich:

I assume the server throws a HTTP 302 redirection when it cannot
identify your request as made from a browser (using HTTP_USER_AGENT).
This is commonly done to avoid scripts scraping data automatically.

The ideal way to solve this would be to switch the HTTP_USER_AGENT
identifier to a standard browser (e.g. IE, Mozilla), but I'm not sure
how to do this.


On 12 September 2011 11:07, Ulrich Kohler <[email protected]> wrote:
> hi all,
> A program of mine wants to copy this file

> from the internet using something like
> . copy
> With Stata 12 I get the error
> --
> file
 not found
> server says file temporarily redirected to

> r(601);
> --
> although the file is shown without problems in a browser.
> Does anybody has an explanation for this?
> Uli

I think this is probably what is going wrong. Verified problem, in both Stata 12 and Stata 11.2. Can't even open the file with fopen() in Mata. Probably the easiest workaround (as I do not think you can tinker with Stata's HTTP_USER_AGENT setting) is to use some local utility, such as curl or wget, e.g. within 
a do- or ado-file,

tempname ctylist
!curl > `ctylist'
type `ctylist'

works on my *nix system; wget may be the utility to use on others.


Kit Baum   |   Boston College Economics & DIW Berlin   |
                              An Introduction to Stata Programming  |
   An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index