0

I have a problem with this script:

#!/bin/bash

data="$(date +\%Y\%m\%d)"

PASSW="pippo"

comando0="cd /remote/path"
comando1="get -r bak*"

cd /local/path
mkdir $data

cd /local/path/$data

(/usr/bin/expect -c "
spawn /usr/bin/sftp user@ip

expect \"Password:\"
send \"$PASSW\r\"

expect \"sftp>\"
send \"$comando0\r\"

expect \"sftp>\"
send \"$comando1\r\"

expect \"sftp>\" 
send "bye\r"

expect \"sftp>\"
send \"exit\r\"
")

On the reomte server there are hundreds of directories called bak*. I need to download these directories and their contents on my local PC. If I connect manually on the remote server and do "get -r bak*" , it works fine. After almost two hours I have all the directories on my PC, while if I use the bash script, this is termintaed after 1 or 2 minutes.

Could you help me ?

Thanks

0 Answers0