4

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

I have the following FTP client conversation:

variscite@variscite-desktop:~$ ftp 192.168.100.10
Connected to 192.168.100.10.
220 (vsFTPd 2.3.5)
Name (192.168.100.10:variscite): anonymous
331 Please specify the password.
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.

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

1 Answer 1

18

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
5
  • wget ftp://anonymous:@192.168.100.10/hello - got it working. Thanks.
    – Alex F
    Nov 7, 2012 at 14:31
  • I added also chmod +x hello since this is executable.
    – Alex F
    Nov 7, 2012 at 14:32
  • What if user name or password includes "@" chareacter like username "[email protected]" or password like "abc@2017"
    – acs
    Jan 25, 2017 at 9:15
  • I would escape those with a "\", so "abc\@ddd.com"
    – Nanne
    Jan 25, 2017 at 13:47
  • Hi, how could we list directory? May 16, 2018 at 9:29

Not the answer you're looking for? Browse other questions tagged .