ls文件名在lftp中不起作用 [英] ls filename does not work in lftp

查看:596
本文介绍了ls文件名在lftp中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个lftp脚本,将单个文件上传到网络托管服务提供商.

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

它有效,但有一个小但令人讨厌的错误.为了检查它是否确实上传了文件,我在末尾添加了ls -l.它失败了,我不明白为什么:

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)   

我尝试使用relscache flush,但徒劳无功.我正在使用lftp 4.0.9.

I tried to use rels and cache flush but in vain. I'm using lftp 4.0.9.

推荐答案

某些Google搜索最终在

Some googling at last gave a result in mail-archive

这是lftp中SFTP协议实现的限制.这不可以 列出单个文件,仅列出特定目录.

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

幸运的是,lftp允许使用管道,所以

Fortunately, lftp allows pipes, so

ls -l | grep  "$FILENAME"

解决了问题.

这篇关于ls文件名在lftp中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆