Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to download files which are outside the my site directory using wget with windows let me make it more clear.

I have my site running on Linux server.

Domain  --->

/var/www/html ---> This is the my site directory

/home/username/data.csv  ---> This is the file I wants to download

When I try to download any file from the site directory it is working fine but it is not getting downloaded from here /home/username/data.csv

c:\wget\ wget.exe --ftp-user="username" --ftp-password="password" ""

The above command works good and 'index.php' file is downloaded successfully.

But how to target /home/username/data.csv file and download using wget?

I tried with this but I was sure this will not work.

c:\wget\ wget.exe --ftp-user="username" --ftp-password="password" ""

I can understand why this command does not work and return 404 error, because the domain is pointing to the /var/www/html directory hence wget internally reads it like /var/www/html/home/username/data.csv and this is true there is no such file.

So my question is Does wget accept the path?

How do I do download the file outside my site directory?

share|improve this question
just looking at the jist, how about -H, to span hosts – barlop Oct 5 '11 at 19:20
oh i see what you're asking, no you cannot obviously. It's simply not on the web or ftp server. though you could start another one on that directory. but ssh will let you copy any file from the terminal. – barlop Oct 5 '11 at 19:22
up vote 1 down vote accepted

How do I do download the file outside my site directory?

You can't ask the web server to provide it, for security reasons.

Try using ftp instead


If FTP service isn't available, configure it or use sftp instead, for greater security.

share|improve this answer
FTP service is not configured and I tried with SFTP wget s but it says Unsupported Scheme – Shakti singh Oct 5 '11 at 10:08
wget doesn't support sftp, there is a separate client program. For Windows you can use WinSCP or Putty's sftp. However you should first check that there is an sshd and sftpd service running on the server and you may need to set up some authentication credentials depending on how the server is configured. How do you upload files to the web-server? – RedGrittyBrick Oct 5 '11 at 10:14
I did it with WinSCP. Thanks – Shakti singh Oct 7 '11 at 9:21

Your web server is only serving files from the /var/www/html/ path and it doesn't know about the existence of /home/username/. You need to launch some kind of a web server instance inside /home/username/ before you can wget files from that directory.

Here are a couple of ways to make that work.

  • Start a temporary HTTP server instance using Python in your home directory.

$ cd /home/username

$ python -m SimpleHTTPServer (python -m http.server on Python 3.x)

$ wget

  • Create a symlink to /home/username/ from /var/www/html/, though this is not recommended as it exposes your entire home directory. Or create the symlink to data.csv itself.

$ cd /var/www/html/

$ ln -s /home/username/data.csv data.csv (ln -s /home/username homedir to symlink the directory)

$ wget

Make sure, that you have enabled using symlinks (globally or for this Directory only) Options FollowSymLinks See here for more documentation regarding symbolic links.

share|improve this answer
okay will give a try – Shakti singh Oct 5 '11 at 10:50
Thanks, I did not tried this way but i think this should work. I did this with WinScp. – Shakti singh Oct 7 '11 at 9:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .