ls filename does not work in lftp

谁说胖子不能爱 提交于 2019-12-12 10:56:49

问题


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

The use case is that I call it from the repository root, so the relative path is the same here and in 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 bug. To check that it really uploads the file, I have put an 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'm using lftp 4.0.9.


回答1:


Some googling at last gave a result in mail-archive

It is a limitation of SFTP protocol implementation in lftp. It cannot list a single file, only a specific directory.

Fortunately, lftp allows pipes, so

ls -l | grep  "$FILENAME"

solves the problem.



来源:https://stackoverflow.com/questions/16185575/ls-filename-does-not-work-in-lftp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!