D
D
Dmitry Rybin2021-05-20 00:34:43
bash
Dmitry Rybin, 2021-05-20 00:34:43

How to delete file in FTP storage using bash?

Hello. I'm trying to execute a script.

# !/bin/bash
echo "Получаю доступ к фтп"
sudo sh -c "ncftpput -u логин -p пароль адрес /"
echo "Начинаю очищать хранилище"
#Допишу потом.
ls
echo "Хранилище очищено | $(date +%y%m%d)"


Once executed, the Ftp client aborts the script, but the connection succeeds. A colleague has the same problem with composer but doesn't know the solution. How to delete a file from FTP storage with one command using bash? Or suggest your own way. Thanks in advance.
sudo sh -c "ncftpput -u логин -p пароль адрес /"


Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xotkot, 2021-05-20
@mb_of

How to delete a file from FTP storage with one command using bash? Or suggest your own way.

I think lftp is better for this
HOST="192.168.1.1"
USER="root"
PASS="12345"
DATE=$(date +%y%m%d)

CMD="\
echo 'Начинаю очищать хранилище';\
ls /;\
echo 'Очищаю .. rm -rf lalala';\
echo 'Хранилище очищено '$DATE;\
exit"

lftp -e "$CMD" --user $USER --password $PASS $HOST

or one team
lftp -e "ls /;rm -rf file.txt;exit" --user root --password 12345 192.168.1.1

S
SOTVM, 2021-05-20
@sotvm

you mount it into the system + delete rm
if the server is puffed, then you can use the server, (here I'm not special, spree = it will cost one line (in the sense of code)
if there are rights

V
Vladimir Korotenko, 2021-05-20
@firedragon

https://blog.eduonix.com/shell-scripting/how-to-au...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question