Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Environment variables in LFTP script

I am trying to run lftp with a script like so:

$ lftp -f deploy.scp

However I would like to use environment variables for l/p inside deploy.scp like so:

open -u $FTP_USER,$FTP_PASSWORD $FTP_HOST;

Is that possible in any way? I have struck out finding any help in the man-pages.

like image 263
Ole Avatar asked Dec 05 '25 18:12

Ole


1 Answers

Although it requires the additional tool envsubst, this worked for me via process substitution

lftp -f <(envsubst < lftp_commands.txt)

assuming I've set those environment variables and lftp_commands.txt contains something like

open --user $FTP_USER --password $FTP_PASSWORD $FTP_HOST
put example.txt
exit

like image 132
ESV Avatar answered Dec 08 '25 07:12

ESV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!