We help IT Professionals succeed at work.

FTP with Wget

fmwebschool
fmwebschool asked
on
Medium Priority
1,364 Views
Last Modified: 2008-08-27
I am finally making progress with FTP and Wget!

I am still having a couple of coding problems however.  Here are the two things that I need to accomplish, and if possible, I will need the exact code.  

I am able to download a file to my "C" drive using this code.

wget
ftp://smarty:pants@ftp.mysite.com/happy.txt --output-document= "c:\happy.txt

I need the exact code as to how to download all of the files in that directory.  If you could show me how using the same code I used above.   And how to get a .txt log or a list of all of the files in the directory, so I can import the list into my database or print it.

Please when you give the code, use my working code above and just add to it.

All of this must work with the command line.

Thank you so much!!
Comment
Watch Question

Commented:

you could try this:

wget -r -11 --no-parent -A.* ftp://smarty:pants@ftp.mysite.com/happy.txt --output-document= "c:\happy.txt


http://linux.about.com/od/commands/l/blcmdl1_wget.htm
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
Actually,

wget ftp://smarty:pants@ftp.mysite.com/*.*

should do that and save the files in your current directory.

Author

Commented:
Thanks guys, I will try this first thing in the morning and let you know how it turns out!  Thank you, will let you know first thing a.m. EST.

In Kindness
Stephen

Author

Commented:
Things are pretty close!  I am trying wget ftp://smarty:pants@ftp.mysite.com/*.* but that just drops the files all over my desktop.  I tried:

wget ftp://smarty:pants@ftp.mysite.com/*.*

I also tried

wget ftp://smarty:pants@ftp.mysite.com/*.* --output-document= "c:\ftp"  and this drops the files all over my desktop instead of into a folder on my "ftp" folder on my "C" drive.

I need to be able to drop all of the documents into the folder, and I need a string that enables me to grab the names of all of the files in a .txt document.

Thank you so much :)  I'm almost there, just deleting dozens of files off my desktop now :)
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
Pack that in a .bat file, e.g.

ftpgetall.bat
--------------------->8---------------------
cd %1
wget ftp://smarty:pants@ftp.mysite.com/*.*
--------------------->8---------------------

and call that like

ftpgetall c:\ftp

Author

Commented:
JKR, (Alias, my hero),

Thank you, I'm going to try it now :)  Thank you !

Author

Commented:
OK here is what I have and here is what happens!

I have a folder on my C: drive named "ftp"

I have created a bat file that looks like this, and saved it to my "C" drive

cd %1
wget ftp://smarty:pants@ftp.mysite.com/*.*

When I run ftpgetall c:\ftp from the command line, a window opens that says
ftp://ftpgetall/

The an FTP Folder Error opens and says:
"Windows cannot access this folder.  Make sure you typed the file name correctly and that you have permission to acces the folder.  Details:  The server name or address could not be resoved.  

It doesn't bring up the dos window, and it doesn't look like wget is even being executed.  I have wget in my windows folder as well as well as directly on my "C" drive in a folder called fmget.  This works,

"c:\fmget\wget.exe ftp://smarty:pants@ftp.mysite.com/*.*  but it dumps the files all over my desktop.  Is there some way I can just code that to just dump into my "ftp" folder on my "C" drive?

Thanks!!!
Stephen


jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
Aer you calling it like

ftpgetall c:\ftp

?

Apart from that, you could 'hard code' a folder like

ftpgetall.bat
--------------------->8---------------------
cd c:\ftp
wget ftp://smarty:pants@ftp.mysite.com/*.*
--------------------->8---------------------

Author

Commented:
Hi JKR :),


Yes I am typing:

ftpgetall c:\ftp

And I have changed the .bat file to:

cd c:\ftp
wget ftp://smarty:pants@ftp.mysite.com/*.*


When I type "ftpgetall c:\ftp " into the command line, a screen immediatlely appears with:  ftp://ftpgetall/ in the address bar, and the same error message.

So, there is no way without the bat file that I can just add it to this string:
"c:\fmget\wget.exe ftp://smarty:pants@ftp.mysite.com/*.* 

and have it save the files to the corrext location?  something like --output c:\ftp?

Thanks for all your help!
Stephen


jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
No, there's no option to specify an putput folder other than cd'ing to the folder you want to use.

Author

Commented:
I see :(  Sooooooo, if I wanted to try this without using the .bat file how would I write the string straight out without the .bat file?

cd c:\ftp "c:\fmget\ wget"  ftp://smarty:pants@ftp.mysite.com/*.*

???

Is that close?

Thanks Stephen
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
It won't work without a batch file, since the Windows command processor does not allow 'command chaining' as as UN*X shell does... Only one command per line, sorry.

Author

Commented:
JKR,

This is what I did, very strange but it downloaded all of the files into my "fmget" folder.  Here is my string

"c:\fmget\ wget.exe"  c:\ftp  ftp://smarty:pants@ftp.mysite.com/*.*


So if that will drop them into my "fmget" folder, how do you think I can rewrite it to drop them into my "ftp" folder instead?

Very close now :)  !!
CERTIFIED EXPERT
Top Expert 2012
Commented:
I gave it a shot, and

--------------------->8---------------------
c:
cd c:\ftp
wget ftp://smarty:pants@ftp.mysite.com/*.*
--------------------->8---------------------

worked fine.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
SMoooooooochhhhhh!   I'm not sure what it was, but I ran it that time and it worked perfectly.  I resaved the above as a .bat file and it ran :)

used C:\try.bat from the command line :)


Thank you so much for sticking with me on this!
Stephen
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
You're most welcome ;o)

(At least I found that no FTP server here allows anonymous login - also a nice side effect *g*)

Author

Commented:
Well :)  Two good things came out of this!  I'm going to continue work away, You know I'll be back with more questions, only half way through this article :)

Thanks again!
Stephen

Author

Commented:
JKR,

Guess what I figured it out without a .bat file.

I simply did this:

wget ftp://smarty:pants@ftp.mysite.com/*.* -P C:\ftp

Hope this is helpful!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.