×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

wget recursive not working like I am expecting it

wget recursive not working like I am expecting it

wget recursive not working like I am expecting it

(OP)
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?

RE: wget recursive not working like I am expecting it

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

RE: wget recursive not working like I am expecting it

(OP)
I tried using the -l1 flag, and I get the same behavior. It downloads all of the directories in front of DDD still.

RE: wget recursive not working like I am expecting it

Hi

The -np should do it, however I only used it over HTTP. Regarding your command :

Quote (JRyanCon)

  • In the code you posted the switches are prefixed with en dash ( ), not hyphen-minus ( - ) characters. Maybe just a posting issue, but better check your script.
  • May not change much, but I would try without the globing * too. Or at least quote it or escape it to avoid getting expanded locally.

Feherke.
feherke.ga

RE: wget recursive not working like I am expecting it

(OP)
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.

RE: wget recursive not working like I am expecting it

Hi

Quote (JRyanCon)

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

RE: wget recursive not working like I am expecting it

(OP)
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?

RE: wget recursive not working like I am expecting it

Hi

Sorry, I am not good in explaining, so I let the manual do it :

Quote (man wget)

       -nH
       --no-host-directories
           Disable generation of host-prefixed directories.  By default,
           invoking Wget with -r http://fly.srk.fer.hr/ 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. 

Feherke.
feherke.ga

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close