Reputation: 289
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.
Upvotes: 4
Views: 2066
Reputation: 7730
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
Upvotes: 1
Reputation: 19395
You can do
<deploy.scp xargs -l sh -c 'eval echo $0 $*' | lftp
or, to save some typing, make an alias, let's say
alias xv=$'xargs -l sh -c \'eval echo $0 $*\''
and then
xv <deploy.scp | lftp
Upvotes: 0
Reputation: 838
If you put this to last line of deploy.scp (*After bye command) :
open -u $FTP_USER,$FTP_PASSWORD $FTP_HOST;
then you can use the following command :
lsftp -f deploy.scp `cat deploy.scp | tail -1`
Upvotes: 0