'Use bash to send command to LFTP and then staying in interactive mode
Forgive the phrasing; haven't done anything with bash for 15 years.
I am trying to write a shell script that will run and connect to lftp and then execute several commands, specifically:
set ftp:ssl-force on
set ftp:ssl-protect-data on
set ssl:verify-certificate no
I then want to remain inside lftp so that I can send additional commands (e.g., I don't know what filename I am downloading until I can do an ls on a remote directory).
When I try to write a bash script to pipe commands to lftp, it works but then also immediately quits lftp when it reaches the last line of the script. Is there a way to prevent that from happening?
Solution 1:[1]
Use lftp's -e
option:
lftp -e 'set ftp:ssl-force on; set ftp:ssl-protect-data on; set ssl:verify-certificate no'
According to lftp's manual:
- -e commands
Execute given commands and don't exit.
Solution 2:[2]
concat stdin after your script
cat yourscript /dev/stdin | your_tftp_command
cat also accept -
as special filename argument for stdin
cat yourscript - | your_tftp_command
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Nahuel Fouilleul |