Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

FTP with Wget

Posted on 2006-03-29
18
Medium Priority
?
1,329 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!!
0
Comment
Question by:fmwebschool
  • 10
  • 7
18 Comments
 

Expert Comment

by:tmkeller
ID: 16328513

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
0
 
LVL 86

Expert Comment

by:jkr
ID: 16328516
Actually,

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

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

Author Comment

by:fmwebschool
ID: 16329417
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:fmwebschool
ID: 16336084
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 :)
0
 
LVL 86

Expert Comment

by:jkr
ID: 16336565
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
0
 

Author Comment

by:fmwebschool
ID: 16339491
JKR, (Alias, my hero),

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

Author Comment

by:fmwebschool
ID: 16345045
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


0
 
LVL 86

Expert Comment

by:jkr
ID: 16345071
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---------------------
0
 

Author Comment

by:fmwebschool
ID: 16345184
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


0
 
LVL 86

Expert Comment

by:jkr
ID: 16345279
No, there's no option to specify an putput folder other than cd'ing to the folder you want to use.
0
 

Author Comment

by:fmwebschool
ID: 16345389
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
0
 
LVL 86

Expert Comment

by:jkr
ID: 16345435
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.
0
 

Author Comment

by:fmwebschool
ID: 16345469
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 :)  !!
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 16345768
I gave it a shot, and

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

worked fine.
0
 

Author Comment

by:fmwebschool
ID: 16346269
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
0
 
LVL 86

Expert Comment

by:jkr
ID: 16346893
You're most welcome ;o)

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

Author Comment

by:fmwebschool
ID: 16347276
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
0
 

Author Comment

by:fmwebschool
ID: 16347561
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!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question