Home > database >  Linux Script Ftp
Linux Script Ftp

Time:01-24

I have to make a script that uploads ONLY [ABC][0-100].txt files ('A' or 'B' or 'C' followed by a number and .txt extension) from the directory current at the URL ftp://host/files/, authenticating with the user admin and password 12345.

I already write some lines but doesn`t working for me:

Script code is:

#!/bin/bash

HOST="host"
USER="admin"
PASSWORD="12345"

DESTINATION=upload

ALL_FILES="A{0..100}.txt B{0..100}.txt C{0..100}.txt"

ftp -inv $HOST <<EOF
user $USER $PASSWORD
cd $DESTINATION
mput $ALL_FILES
bye
EOF

can u help me grep only file with specified name

CodePudding user response:

With bash version >= 3.1 I suggest to replace

ALL_FILES="A{0..100}.txt B{0..100}.txt C{0..100}.txt"

with

printf -v ALL_FILES "%s " A{0..100}.txt B{0..100}.txt C{0..100}.txt

to allow bash to expand the expression.

I can't tell you if there are any other problems in your code. I recommend to write all self-defined variable names in lower case.

  •  Tags:  
  • Related