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.