wget - I can't download files with "?"

6

1

I wanted to download some tuts on aircrack by wget and I failed:

wget -r 2 http://www.aircrack-ng.org/doku.php\?id=tutorial\&DokuWiki=78e8249415a9ce232228ed8f9f02b9dd 
--2011-10-06 14:16:11--  http://2/
Resolving 2... 0.0.0.2
Connecting to 2|0.0.0.2|:80... failed: Invalid argument.
--2011-10-06 14:16:11--  http://www.aircrack-ng.org/doku.php?id=tutorial&DokuWiki=78e8249415a9ce232228ed8f9f02b9dd
Resolving www.aircrack-ng.org... 213.186.33.2, 2001:41d0:1:1b00:213:186:33:2
Connecting to www.aircrack-ng.org|213.186.33.2|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
www.aircrack-ng.org/doku.php?id=tutorial&DokuWiki=78e8249415a9ce232228ed8f9f02b9dd: Invalid argument

Cannot write to `www.aircrack-ng.org/doku.php?id=tutorial&DokuWiki=78e8249415a9ce232228ed8f9f02b9dd' (Invalid argument).

Do you know how to fix this problem ?

oneat

Posted 2011-10-06T12:15:44.813

Reputation: 2 823

I can't reproduce the problem, but you should remove the 2 after -r (that option doesn't take an argument). – Kusalananda – 2011-10-06T12:30:26.070

Answers

8

This is probably the filesystem you're downloading to not allowing a filename with "?" in it. Note that the error is "Cannot write".

You can use the --restrict-file-names=windows option to escape names for compatibility with FAT filesystems. (Note that the non-reversible additional %-encoding done by wget is not actually correct vs. web architecture, but you probably don't care.)

You could also use -O <filename> to specify a particular filename if you were downloading only one file.

Kevin Reid

Posted 2011-10-06T12:15:44.813

Reputation: 2 854

--restrict... solved this for me, using Ubuntu bash on windows 10 – chwi – 2018-08-31T08:13:07.913

4

The & also commonly causes problems. Try putting the whole url in quotes.

pjc50

Posted 2011-10-06T12:15:44.813

Reputation: 5 786

2

As suggested by pjc50, please put the URL within quotes when you have special characters in it. Therefore, you should try:

wget -r 2 'http://www.aircrack-ng.org/doku.php?id=tutorial&DokuWiki=78e8249415a9ce232228ed8f9f02b9dd'

When you do not use quotes, the shell, on encountering a &, assumes you want to run the wget job in background.

Barun

Posted 2011-10-06T12:15:44.813

Reputation: 146