I trying to run a script that get a latest file create in my FTP server.
file=`ls -t -r | tail -n 1`
sudo lftp <<FTP
open $hostname
user $username $password
cd $folder
get $file
bye
FTP
But the ls command in file variable execute in my local machine. What´s wrong? Thank you.