I have the following command that use to upload a single file to my ftp and it works fine on my OS X El Capital 10.11.4
ftp -in -u ftp://username:password@servername/path/to/ localfile
Questions
- what does -in stands for?
- Is there a similar single line command for download all or a particular file?
- Is there a similar single command to list files/folders on the ftp?
Tests based on Answers that didn't work
- ftp -in -u localfile ftp://username:password@servername/path/to/
didn't work as it complained ftp: Invalid URL `localfile' because it's expecting URL to be after -u - Also tried
ftp -in localfile -u ftp://username:password@servername/path/to/
then it said usage: ftp host-name [port]
so it seems we can't move the URL to the end either
Tests based on answers that did work
- ftp -in ftp://username:password@servername/path/to/file.zip /local/path using this i was able to download single file
- ftp ftp://username:password@servername <<< "ls"
This worked to list
More Comments
After getting the idea from answer around <<< "ls"
I tried
ftp -in ftp://username:password@servername/ <<< "mget *" ' this lets me download all the files
Best Answer
Type
man ftp
in terminal. If will bring up the manual and have all the info you are requesting.-i Turns off interactive prompting during multiple file transfers.
-n Restrains ftp from attempting ``auto-login'' upon initial connection for non auto-fetch transfers. If auto-login is enabled, ftp will check the .netrc (see below) file in the user's home directory for an entry describing an account on the remote machine. If no entry exists, ftp will prompt for the remote machine login name (default is the user identity on the local machine), and, if necessary, prompt for a password and an account with which to login. To override the auto-login for auto-fetch transfers, specify the username (and optionally, password) as appropriate.
Just tested this one.
try this
at first I figured ls and dir would be different depending on the server OS. However the man page says dir is OS agnostic so that should be better
dir [remote-path [local-file]] Print a listing of the contents of a directory on the remote machine. The listing includes any system-dependent information that the server chooses to include; for example, most UNIX systems will produce output from the command
ls -l'. If remote-path is left unspecified, the current working directory is used. If interactive prompting is on, ftp will prompt the user to verify that the last argument is indeed the target local file for receiving dir output. If no local file is specified, or if local-file is
-', the output is sent to the terminal.