Ls filename not working in lftp

I created an lftp script to upload individual files to a web hosting provider.

The use case is that I call it from the root of the repository, so the relative path here is the same on the remote server.

#!/bin/bash DIRNAME=$(dirname $1) FILENAME=$(basename $1) REPO_ROOT=$(pwd) ABSOLUTE_PATH=${REPO_ROOT}/$1 lftp -u user,passwd -p port sftp:// user@hosting <<EOF cd $DIRNAME put $ABSOLUTE_PATH ls -l $FILENAME quit 0 EOF 

It works with one small but annoying mistake. To check if it really loads the file, I put ls -l at the end. It fails, and I do not understand why:

 ls: Access failed: No such file(functions.php) 

I tried to use rels and cache flush , but in vain. I am using lftp 4.0.9.

+4
source share
1 answer

Some search queries finally returned a result in mail-archive

This is a limitation of the implementation of SFTP in lftp. It cannot specify a single file, only a specific directory.

Fortunately, lftp allows you to use pipes, so

 ls -l | grep "$FILENAME" 

solves the problem.

+6
source

All Articles