Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wget recursive not working like I am expecting it 1

Status
Not open for further replies.

JRyanCon

Technical User
Aug 19, 2004
47
US
I am trying to download all files and folders from a particular folder. If I turn on recursive, it downloads all of the folders leading up to the folder I want, which I do not want. I tried adding –np or --no-parent, but I get the same behavior, so I don’t think I am using the command correctly.

From a bash script I tried running: wget –r –np ftp://10.10.10.10/AAA/BBB/CCC/DDD/*

I want all files, folders (and their files) from only DDD. When I run the above command what I get is all of the folders:
10.10.10.10/AAA/BBB/CCC/DDD/<all folders and files under DDD>

I have tried different iterations of the command above but always the same behavior. What’s the correct syntax?
 
add -l1 (folder depth level 1 only) to the command so it is only 'recursive' for a single level

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
I tried using the -l1 flag, and I get the same behavior. It downloads all of the directories in front of DDD still.
 
Hi

The [tt]-np[/tt] should do it, however I only used it over HTTP. Regarding your command :
JRyanCon said:
wget [highlight]–[/highlight]r [highlight]–[/highlight]np ftp://10.10.10.10/AAA/BBB/CCC/DDD/[highlight pink]*[/highlight]
[ul]
[li]In the code you posted the switches are prefixed with en dash ( [highlight]–[/highlight] ), not hyphen-minus ( - ) characters. Maybe just a posting issue, but better check your script.[/li]
[li]May not change much, but I would try without the globing [highlight pink]*[/highlight] too. Or at least quote it or escape it to avoid getting expanded locally.[/li]
[/ul]

Feherke.
feherke.ga
 
The dash issue is just because I typed my message into Outlook first to catch any spelling or grammatical errors.

I have tried several different options like:
wget -r -np -l1 ftp://10.10.10.10/AAA/BBB/CCC/DDD/*
wget -r -np -l1 ftp://10.10.10.10/AAA/BBB/CCC/DDD
wget -r -np -l1 ftp://10.10.10.10/AAA/BBB/CCC/DDD/

None of them just download whats in DDD. They all give me the full folder tree leading up to DDD.
 
Hi

JRyanCon said:
None of them just download whats in DDD. They all give me the full folder tree leading up to DDD.
Wait a moment. You mean that parent directories are just created or they are also populated ?

If you not want DDD/'s parent directories created, then this should do it ( also tried only over HTTP ) :
Code:
wget -r -np -nH --cut-dirs=3 ftp://10.10.10.10/AAA/BBB/CCC/DDD/


Feherke.
feherke.ga
 
they are created, but there is nothing else in those directories but the next folder. I just dont want them.

That command you just gave did what I wanted it to! Care to explain it?
 
Hi

Sorry, I am not good in explaining, so I let the manual do it :
man wget said:
[pre]
-nH
--no-host-directories
Disable generation of host-prefixed directories. By default,
invoking Wget with -r will create a
structure of directories beginning with fly.srk.fer.hr/. This
option disables such behavior.

--cut-dirs=number
Ignore number directory components. This is useful for getting a
fine-grained control over the directory where recursive retrieval
will be saved.[/pre]


Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top