Possible Duplicate:
How do I execute FTP commands on one line?

I have the following FTP client conversation:

variscite@variscite-desktop:~$ ftp
Connected to
220 (vsFTPd 2.3.5)
Name ( anonymous
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> get hello hello
local: hello remote: hello
200 PORT command successful. Consider using PASV.                                                                       
150 Opening BINARY mode data connection for hello (7796 bytes).                                                         
226 Transfer complete.                                                                                                  
7796 bytes received in 0.01 secs (702.8 kB/s)                                                                           
ftp> exit                                                                                                               
221 Goodbye. 

Is it possible to do this in one command, or write a shell script which does the same? Client computer is Ubuntu 12.04, and I need to do this without installing additional packages.

  • I never tried this with FTP, but I think you just need to specify these commands in a bash file. – Evandro Silva Nov 7 '12 at 13:21
  • @Rinzwind - I cannot use the answer to this question, because lftp is not available. – Alex F Nov 7 '12 at 13:42
  • Ok :) do you have scp? I always use scp for this. – Rinzwind Nov 7 '12 at 13:45
  • @Rinzwind - yes, scp is available. – Alex F Nov 7 '12 at 13:46

While I agree that scp is better, it's not only that your client needs the scp command, your server needs to support that as well ofcourse. Enough situations where you can just reach the server through FTP, isn't there?

If you want to get a file from FTP you could just use wget ?

wget ftp://username:password@SERVERNAME/directory/file
  • wget ftp://anonymous:@ - got it working. Thanks. – Alex F Nov 7 '12 at 14:31
  • I added also chmod +x hello since this is executable. – Alex F Nov 7 '12 at 14:32
  • What if user name or password includes "@" chareacter like username "abc@ddd.com" or password like "abc@2017" – acs Jan 25 '17 at 9:15
  • I would escape those with a "\", so "abc\@ddd.com" – Nanne Jan 25 '17 at 13:47
  • Hi, how could we list directory? – LoranceChen May 16 '18 at 9:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.