Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-29-2009, 01:18 PM   #1
Senior Member
Registered: May 2008
Distribution: Slackware
Posts: 1,033

Rep: Reputation: 69
how do I write a script for ftp to get *.mp3 files?

I want to know how to write a script that would use the standard Linux FTP command to download all the mp3 files from a FTP server cause GET *.mp3 doesn't work. Also how would I write the same script but as a batch file to be run in windows cmd through the windows native FTP command?
Old 03-29-2009, 01:32 PM   #2
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
If you don't have a specific reason to use ftp (the program), you could just as well use wget; it allows for recursive downloading and limiting to certain file extensions, for example .mp3 in your case. The man page of wget contains all you need, but probably you'll do fine with arguments for recursive downloading (-r) and accepting mp3 suffix (-A.mp3); if you need to, you can also restrict the download to given depth (of subdirs), tell it to (not to) create directories etc. I think the short way is

wget -r -A.mp3
see if it works..

By the way, what problems did you have using
mget *.mp3
with ftp (m in the mget as in "multiple")? Or did I get you wrong?

Last edited by b0uncer; 03-29-2009 at 01:34 PM.
Old 03-29-2009, 02:41 PM   #3
Senior Member
Registered: May 2008
Distribution: Slackware
Posts: 1,033

Original Poster
Rep: Reputation: 69
Aye that works quite nicely, However I would like to know how a script would look like using normal FTP.
Old 03-29-2009, 03:50 PM   #4
LQ Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289Reputation: 1289
Dunno about ftp, I don't have it installed, but with lftp you can do something like I posted here:
Old 03-29-2009, 07:47 PM   #5
Senior Member
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
usually, you would use the here document
  ftp -n server <<EOF
  user username password


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to move or set write permissions for files taken from an mp3 player ton_vb Linux - Newbie 3 09-24-2006 03:16 AM
How to write a FTP script???? kabucek General 2 08-25-2006 08:46 AM
Able to write files to MP3 player but no files written into actual device? olnex Linux - Hardware 0 11-11-2005 06:32 AM
How to write a shell script to download a file via FTP? guarriman Linux - General 4 12-21-2004 09:31 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration