03 - Open Source (EN)03f - Tools Open Source (EN)

Open Source – Lftp – Not just ftp and sftp

Last Updated on 1 May 2020 by Roberto De Pedrini

The opening of IBM i to the Open Source world allows you to install languages and tools that simplify the processes of our business applications.

For example, a typical case is that of SFTP which has replaced the old FTP in various corporate data exchange processes (shipments with couriers, border ships, etc.).

If we have to exchange files with SFTP, we do not always have the possibility of making clients and servers “trusted” through an exchange of RSA keys which guarantee secure communication without having to exchange passwords every time.

If we must continue to use the user and password, batch script management is not as simple as we are used to doing with FTP and we have to resort to utilities (always from the open source world) such as Expect: we always talked about it on this blog a few months ago : SFTP with password (no SSH key authentication).

An interesting alternative, which opens IBM i in addition to ftp and sftp also to other protocols such as torrent, is “LFTP”

Lftp allows you to create scripts similar to those we used with FTP … with user and password in the script itself, losing something from an internal security point of view for the benefit of simplicity, also opening up a world of new possibilities such as SFTP, TORRENT, HTTP, upload – download bandwidth control, resumption of downloads in case of outage, mirror functionality (rsync-style) between client and server directories.

In conclusion … small, but really powerful, open source package: let’s see how to install and use it in the IBM i environment

From QSH environment, or better, with an SSH terminal connected to the IBM i PASE environment:

bash-4.4 $ yum install lftp

We follow the installation steps and start testing it on a public SFTP server and download an entire directory of the server into our own IFS directory.

Public SFTP Server: demo.wftpserver.com
Port: 2222
User: demo-user
Password: demo-user

Now create a new directory on our IFS
bash-4.4 $ mkdir / home / faq400 / wftp_download

Then we can download to the remote directory with this command with an integrated script:

bash-4.4 $ lftp -c "set ssl: verify-certificate no; set sftp: auto-confirm yes; open sftp: // demo-user: demo-user@demo.wftpserver.com: 2222; lcd / home / faq400 / wftp_download; cd download; mget *; quit "

In the above case, we download a whole directory. If it is a periodic operation it might make sense to reason “incrementally” by going to download only the files modified since the last download:

bash-4.4 $ lftp -c "set ssl: verify-certificate no; set sftp: auto-confirm yes; open sftp: // demo-user: demo-user@demo.wftpserver.com: 2222; mirror --verbose - -use-pget-n = 8 -c / home / faq400 / download / pdf / 2020 / testmirror /; quit "

LFTP options are really many … here are some examples:

mget -c to continue interrupted download

set net: limit-rate 0: 512000 to limit upload bandwidth
set net: limit-total-rate 3M: 500K to limit download and upload

lftp -e 'pget -c -n 5 / path / to / file' sftp: // username @ server Multiparts transfer

LFTP, a really interesting open source package for file transfer management also in IBM i environment

Related Posts
DB2 for i SQL – String Manipulation – POSSTR-LOCATE-LOCATE_IN_STRING (EN)

Introduction Often, in our applications, we need to work with text strings, and DB2 SQL can come in very useful Read more

DB2 for i – FAQ & Howtos (EN)

DB2 Database and SQL ... maybe the most important things on IBM i platform: here's a collection of FAQs, tips Read more

IBM i 7.4 Announcement (En)

Comes directly with the Easter egg this IBM announcement for the news of the IBM i 7.4 version, iNext version Read more

Generated Always Columns (EN)

Introduction "Generated Always Column": are columns, table fields, filled by DB2 engine: something like columns with a default value but Read more

--- Roberto De Pedrini Faq400.com
About author

Founder of Faq400 Srl, IBM Champion, creator of Faq400.com and blog.faq400.com web sites. RPG developer since I was wearing shorts, strong IBM i supporter, I have always tried to share my knowledge with others through forums, events and courses. Now, with my company Faq400 Srl, I help companies to make the most of this great platform IBM i.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *