LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
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
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

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
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

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

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
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,697
Blog Entries: 5

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


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:28 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration