LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

Rep: Reputation: 56
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
b0uncer
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

Code:
wget -r -A.mp3 ftp://address.to.the.site/somedir
see if it works..

By the way, what problems did you have using
Code:
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
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 972

Original Poster
Rep: Reputation: 56
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
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
Dunno about ftp, I don't have it installed, but with lftp you can do something like I posted here:
http://www.linuxquestions.org/questi...4/#post3483244
 
Old 03-29-2009, 07:47 PM   #5
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

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


Reply


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


All times are GMT -5. The time now is 10:42 AM.

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