LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-14-2018, 12:44 PM   #1
adra1190
LQ Newbie
 
Registered: Apr 2018
Posts: 9

Rep: Reputation: Disabled
Script FTP


Hi people,

I have a litle question how I can download files from un file called "X". In file "X" I have the name for many files and need download with mget the files that are listing in "X".

I tried with:

mget X
mget !cat X
mget !X

Thanks for the help!!!
 
Old 08-14-2018, 01:06 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,637

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by adra1190 View Post
Hi people,
I have a litle question how I can download files from un file called "X". In file "X" I have the name for many files and need download with mget the files that are listing in "X".

I tried with:

mget X
mget !cat X
mget !X
You don't provide any details (version/distro of Linux, which FTP server and client, etc.), so its hard to say. If you're asking how to script this, you can write a bash/expect script that loops through your input file, and gets them one at a time. You *REALLY* shouldn't be using FTP anyway, as it's slow and insecure. If you use SCP, you can simply do a keyswap with your remote host, and type in
Code:
scp user@remote.host:/some/path/*X* /some/local/path
...and it's done.
 
2 members found this post helpful.
Old 08-14-2018, 01:37 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
What's an "un file"?

The rest of your question also is unclear.

Is X a file which describes other files?

As a pure guess, how about you get X, and then parse X to get the rest of the files.

Further, it's worth looking at scp as well as the -r option.

mget for FTP is only something you can use with a wildcard, like "mget *" or "mget *.jpg"

You can read my bash blog, (link in my signature) for some bash tips. A primary point I make is that if you can type it, you can script it. So, figure out what to type to accomplish this and then script it. We can help you with improving the efficiency of a script once you show us on. If you don't now how to script much at all, then please start a bit before attempting something more complex.
 
1 members found this post helpful.
Old 08-14-2018, 01:41 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,728

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
What is in file X?
If I remember correctly* mget will accept a space-delimited list of file, as:
Code:
mget file1 file2 file3
If the file has such a list, then
Code:
ftp>mget !cat X
should work.

*As TBOne said, FTP is no longer recommended, and I don't use it anymore, or even have it installed, so I can't do:
Code:
ftp>help mget
to confirm my memory.
 
1 members found this post helpful.
Old 08-14-2018, 02:25 PM   #5
adra1190
LQ Newbie
 
Registered: Apr 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
In file X is the list for all files in a directory
 
Old 08-14-2018, 02:33 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,637

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by adra1190 View Post
In file X is the list for all files in a directory
Ok, so back to "write a script to loop through that, and get the files". What have you done so far? And as we've said, consider scp with the usage mentioned.
 
Old 08-14-2018, 07:47 PM   #7
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,728

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by adra1190 View Post
In file X is the list for all files in a directory
Yeah. We didn't need you to repeat that...

I was asking you to show us what's in the file.

Is it one file per line? Then write a script per TB0ne's suggestion...forget mget. (or use scp...)
 
  


Reply

Tags
ftp



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
Help with a ftp script ginda Programming 2 11-23-2010 08:30 AM
Bash script problem with ftp session exiting the script early edomingox Programming 5 02-23-2010 05:39 AM
Urgent Help: Perl FTP Script Using NET::FTP xboxter Programming 8 05-16-2005 06:57 PM
FTP script Veteq Programming 3 04-21-2004 12:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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

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