2

I want to download a specific file to a specific folder on the server using lftp. The problem is that when I download the file, it stays in the root folder. How do I download the file to my home?

Example code:

host_File=$(lftp -e "open -u ${user},${pass}; ls; exit" $host_SFTP |
  grep "$date" | grep -oE "$host_File")
lftp -e "-u $user, $passc; get $host_File; exit" $host_SFTP
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

1

You have several options:

  • Change to the target folder using cd, before you execute lftp:

    cd /target/path
    lftp -e "-u $user, $passc; get $host_File; exit" $host_SFTP
    
  • Use lcd within lftp:

    lftp -e "-u $user, $passc; lcd /target/path; get $host_File; exit" $host_SFTP
    
  • Use -O switch of the get command to specify the target folder:

    lftp -e "-u $user, $passc; get -O /target/path $host_File; exit" $host_SFTP
    
  • Use -o switch of the get command to specify the target file:

    lftp -e "-u $user, $passc; get $host_File -o /target/path/file; exit" $host_SFTP
    

See https://lftp.yar.ru/lftp-man.html

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992