-   Linux - Software (
-   -   how do i wget a url with spaces (

xmrkite 12-20-2007 05:09 PM

how do i wget a url with spaces
hello, i am trying to do two things, one is read url's from a file, then wget (download) them all.

Here is my code:


  cat $url_file | while
  read url
      VAR2="`ps | grep feh | nawk '{ print $1}'`"
      wget -O /home/xmrkite/$url$url

The problem is that when the filenames on the website have a space in them, wget gives me a 400 bad request error. How can i fix this?


PS. I also want to have it download the files in the txt file from random lines instead of going in order...but not knowing beforehand how long the file will be, how can i do that? The file has one filename per line, all the files being in the same directory on the webserver.

gilead 12-20-2007 05:12 PM

Have you tried wrapping the URL strings in quotes?

wget -O "/home/xmrkite/$url" "$url"

xmrkite 12-20-2007 05:28 PM

I tried that, but it doesn't work. I'm really stumped.

I had tried using ' ` and " in various arrangements, but to no avail. Any other ideas?

I know the url is good cause i can copy it into firefox and get the file. So something else must be going wrong.

gilead 12-20-2007 05:48 PM

The quotes work for me - did you get an error message when you tried it? Failing that, you may be able to convert the space characters to %20 (I haven't tried that here).

chrism01 12-20-2007 06:00 PM

Try escaping the spaces with \ char first

xmrkite 12-20-2007 06:17 PM

OK, it worked fine on my ubuntu computer, but on my DSL Linux computer, it didn't work. Why they heck would this be. I just don't get it. Any other ideas???

I tried just a simple

wget " with spaces.txt"

And on dsl linux, it didn't work.


Brian1 12-20-2007 06:51 PM

Might run the command on each machine to get the version number.
wget --version

Now check the developers site and see if there is any issues with the one that does not work right or maybe install the latest wget.


xmrkite 12-21-2007 12:15 PM

ok, i installed the gnu-utils program from the mydsl extension loader, and that solved my problem. They probably just put in a trimmed down version of the program to save space. DSL Linux is very small after all.

All times are GMT -5. The time now is 11:07 AM.