lftp and editing remote files

lftp is a very nice piece of software (for people who like text console).

How to edit remote files? Take a look!


[arekm@tarm ~]$ cat .lftp/rc
alias edit source -e ~/.lftp/edit.sh
[arekm@tarm ~]$ cat .lftp/edit.sh
#!/bin/sh
tempid=$$
echo get $1 -o /tmp/$tempid$1
echo shell vim /tmp/$tempid$1
echo put -E /tmp/$tempid$1 -o $1
[arekm@tarm ~]$ lftp -u arm ftp.somewhere.pl
Password:
lftp arm@ftp.somewhere.pl:~> ls
drwxr-xr-x 2 0 0 4096 Jan 29 20:35 .
drwxr-xr-x 2 0 0 4096 Jan 29 20:35 ..
lftp arm@ftp.somewhere.pl:~> edit test.txt
get: Access failed: 550 Can't open test.txt: No such file or directory

[HERE vim is opened; after saving]

9 bytes transferred
lftp arm@ftp.somewhere.pl:~> rels
drwx---r-x 3 10089 999 50 Jun 15 18:35 .
drwxr-xr-x 2 0 0 4096 Jan 29 20:35 ..
-rw-r--r-- 1 10089 nogroup 9 Jun 15 18:35 test.txt
lftp arm@ftp.somewhere.pl:~> cat test.txt
El test.
10 bytes transferred
lftp arm@ftp.somewhere.pl:~> edit test.txt
9 bytes transferred

[HERE again vim is opened; after saving]

23 bytes transferred
lftp arm@ftp.somewhere.pl:~> cat test.txt
El test.
Small change.
25 bytes transferred
lftp arm@ftp.somewhere.pl:~>

Don’t we all love lftp?

201504 EDIT: lftp 4.6.1 will have edit command built in!

3 thoughts on “lftp and editing remote files

  1. hjubal says:

    Great!

    File autocompletion does not work.
    Do you know why?

    thx

    Reply to hjubal

  2. lliseil says:

    Hi, cool script, thank you ! lftp (v 4.6.1) default alias for edit does not work here.

    Reply to lliseil

Leave a Reply

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