Saturday, November 21, 2015

Command lines for for FTP

Hello,

In this post we will talk about using FTP services from a command line.

So to connect to an FTP server, you have to log on first by typing "ftp sitename" or "ftp ipaddress"
where "ipaddress" is the ip address of the FTP server, or sitename is the Fully qualified domain name of the ftp server.

Once you type this command, you will prompted for a username then a password. The username and the password are the ones created for you on the FTP server.

Here are screenshots

The most used commands:
"get filename1" this will transfer the file named "filename" from the FTP server to your PC. you have to type the filename completely (including the extension .jpg, .txt...)
"put filename2" this will transfer the filename2 located in your PC to the FTP server. Same as get command, the name of the file must be written completely.

What if we need to transfer more than one file ? We have "mget" and "mput"
If we type "mput *" it will start copying files from our local directory to the FTP server. But before copying each file we will be prompted.
If we type "mget *", files will be copied from the FTP server (the directory that we are in) to our local directory, and we will be prompted to confirm for each file.

If we don't want to be prompted for each file; so before using the "mput" or the "mget", we type "prompt" this will turn the interactive transfer off .

The transfer types:  There is different transfer types. The most known transfer types are ASCII and binary.
Text Files from different platforms (Windows, Unix..) have different kinds of line ending.
FTP ASCII transfer type sometimes do translations for lines ending.
Binary transfers the file same as it is
If you are doing a migration for a specific software or database from a windows to a Linux and vice-versa, and in the migration you have to export/import data, and if you are using FTP to transfer these data, you better change the mode binary.
It happened to me once I was migrating from CiscoWorks on Windows to a CiscoPrime LMS appliance based on Linux. When trying to import the data exported from the windows, the Linux based appliance was seeing the data corrupted. After I changed the mode to binary, the import worked successfully into the Cisco LMS appliance.

I will add some screenshots to explain more about these commands, we will also talk about other commands in FTP.

I hope this was helpful, and I would like to thank you for reading



 

No comments:

Post a Comment