简体   繁体   中英

Execute mirror and mget lftp commands in bash script

Current code

#!/bin/bash
SFTP_SERVER="sftp.url.com:/csv/test/10"
SFTP_USER="user"
SFTP_PWD="pwd"

## not sure if this line is needed given I specify the local directory
# in the next block of code.
cd /mnt/c/Users/user/Documents/new_directory    
lftp sftp://$SFTP_USER:$SFTP_PWD@$SFTP_SERVER
lftp -e mget *.csv mirror sftp.user.com:/csv/test/10 /mnt/c/Users/user/Documents/new_directory

Objective

Download all csv files and mirror my local directory folder with the remote server, so when the code is run again it won't download a second file.

Error received

open: *.csv: Name or service not known

Comments

From what I understood of the lftp man page I should be able to get all wildcard files by using mget instead of the standard get , provided I use -e to use external commands. I've run mget manually and can download the files without issue but it doesn't seem to support the *.csv in the script.

Appreciate any feedback you can provide as to why my code won't download the files and what I might have misunderstood from the man pages.

It should be like:

lftp sftp://$SFTP_USER:$SFTP_PWD@$SFTP_SERVER -e "mget *.csv; bye"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM