What is the use of literal command in ftp?

7,313

FTP has quite a few commands. While the client maps some of these to a more userfriendly text interface.

For example, if you use ftp -v (depending on your ftp client, the one I use needs ftp -vd), you'll notice something like the following (---> shows what is sent to the server):

$ ftp -vd ftp.debian.org
Connected to ftp.debian.org.
220 ftp.debian.org FTP server
Name (ftp.debian.org:user): anonymous
---> USER anonymous
331 Please specify the password.
Password:
---> PASS XXXX
230 Login successful.
[...]
ftp> cd debian
---> CWD debian
250 Directory successfully changed.

That is, your convenient cd calls get mapped to CWD commands.

Some FTP clients allow you to send verbatim FTP commands to the server; in yours it is done with literal (my ftp uses quote):

ftp> quote CWD ..
---> CWD ..
250 Directory successfully changed.

Useful? Indeed, it allows you to interact with your FTP server in ways the client doesn't know about. Maybe your client doesn't implement SITE commands, then you could still use literal SITE [...] to have the server do what you want. Things like FXP can be done with any FTP client using handcrafted commands, too (albeit quite inconveniently). Also, for experimenting with FTP, it's more comfortable to have the login process handled by the FTP client and use literal commands afterwards (compared to using telnet/netcat only).

However, what the server understands obviously depends on your server:

ftp> quote foobar
---> foobar
500 Unknown command.
Share:
7,313

Related videos on Youtube

ekoeppen
Author by

ekoeppen

Updated on September 18, 2022

Comments

  • ekoeppen
    ekoeppen over 1 year

    Browsing through FTP help (i.e. ftp> ?), showed me a command name literal, description of which is

    ftp> ? literal
    literal         Send arbitrary ftp command
    

    I tried to do some trial and error, and following is the terminal output. All returned 500 Unknown command.

    ftp> literal check
    500 Unknown command.
    ftp> literal bye
    500 Unknown command.
    ftp> literal
    Command line to send check
    500 Unknown command.
    ftp> literal
    Command line to send ascii
    500 Unknown command.
    

    I would like to know more about this literal command and in what scenarios is it helpful?

    Edit

    Note: I am connecting a unix machine from windows 7 command prompt. And I see both literal and quote in ftp help.

  • ekoeppen
    ekoeppen over 11 years
    Thanks for the info. I see both literal and quote and both are working. So, isn't that redundant?
  • sr_
    sr_ over 11 years
    Is it? You might get used to literal, but I might still prefer (and expect to find) quote... (this might be a rather weak argument)
  • kevinmicke
    kevinmicke over 9 years
    In the default Windows FTP program, both literal and quote work, but on at least some Unix FTP programs only quote works, so quote seems to be the most widely used in my experience.
  • Geremia
    Geremia almost 3 years
    "FXP can be done with any FTP client" Really? How?