viernes, 16 de marzo de 2018

Cómo usar FTP desde la linea de comandos

How do I use FTP from a command line?

Updated: 05/05/2017 by Computer Hope
Note: FTP is not an encrypted transmission, which means any data sent over it, including your username and password, could be read by anyone who may intercept your transmission. If you're wanting a more secure transmission, we suggest using SFTP.

Connect using FTP

To connect to another computer using FTP at the MS-DOS prompt, command line, or Linux shell type FTP and press Enter. Once in FTP, use the open command to connect to the FTP server, as shown in the example below.
open ftp.example.com
In the above example, you'd substitute example.com for the domain name or IP address of where you are connecting. An example would be open 192.168.1.12.
Note: By default, the open command uses the TCP port 21 to make the FTP connection. If a different TCP port is needed for connecting to the domain name or IP address you are using, enter the port number after the domain name or IP address in the open command.
Once connected, a username and password prompt will appear. Once these credentials have been entered, the server allows you to browse, send, or receive files, depending on your rights. Some servers may also allow anonymous logins using guest or an e-mail address.

Send and receive a file in FTP

To get files from the server onto your computer, use the get command as shown in the example below. In this example, you would get the file myfile.htm.
get myfile.htm
Tip: If you want to get more than one file, use mget and wildcards. For example, if you wanted to get all files that end with .htm, you could type mget *.htm. Finally, if you do not want to be prompted as each file is being sent, make sure to type prompt to disable prompting.
To send a file from your computer to the computer you are connected to, assuming you have the rights, use the send command as shown in the example below. In this example, we are sending the myfile.htm to the current directory.
send myfile.htm
It is important to realize that the files being sent must be in your local working directory, which is the directory you were in when you typed the FTP command. If you want to change to the directory that contains your files, use the lcd command. For example, in Windows, you'd type lcd c:\windows to set the local directory to the Windows directory.

FTP Commands

Depending upon the version of FTP and the operating system being used, each of the below commands may or may not work. Typing -help or a ? will list the commands available to you. Below is a general description of FTP commands available in the Windows command line FTP command.


CommandInformation
!This command toggles back and forth between the operating system and ftp. Once back in the operating system, typing exit takes you back to the FTP command line.
?Access the Help screen.
appendAppend text to a local file.
asciiSwitch to ASCII transfer mode
bellTurns bell mode on or off.
binarySwitches to binary transfer mode.
byeExits from FTP.
cdChanges directory.
closeExits from FTP.
deleteDeletes a file.
debugSets debugging on or off.
dirLists files if connected.

dir - C = Will list the files in wide format.
dir -1 = Lists the files in bare format in alphabetic order
dir -r = Lists directory in reverse alphabetic order.
dir -R = Lists all files in current directory and sub directories.
dir -S = Lists files in bare format in alphabetic order.
disconnectExits from FTP.
getGrabs file from the computer to which you are connected.
globSets globbing on or off. When turned off the file name in the put and get commands is taken literally and wildcards are not used.
hashSets hash mark printing on or off. When turned on for each 1024 bytes of data received a hash-mark (#) is displayed.
helpAccess the Help screen and displays information about command if command typed after help.
lcdDisplays local directory if typed alone or if path typed after lcd will change local directory.
literalSends a literal command to the connected computer with an expected one line response.
lsLists files of the remotely connected computer.
mdeleteMultiple delete.
mdirLists contents of multiple remote directories.
mgetGet multiple files.
mkdirMake directory.
mlsLists contents of multiple remote directories.
mputSent multiple files
openOpens address.
promptEnables or disables the prompt.
putSend one file
pwdPrint working directory
quitExits from FTP.
quoteSame as the literal command.
recvReceive file.
remotehelpGet help from remote server.
renameRenames a file.
rmdirRemoves a directory on the remote computer.
sendSend single file.
statusShows status of currently enabled and disabled options
traceToggles packet tracing.
TypeSet file transfer type.
userSend new user information.
verboseSets verbose on or off.
Fuente: https://www.computerhope.com/issues/ch001246.htm

Jesús Moreno - Ingeniero Ténico Informático - consultor Informático

Hola, soy Jesús Moreno Ingeniero Técnico Informático en sistemas por la US y propietario de éste blog. Mi trabajo en los ultimos años se ...