find ./file-name "*.mp4" -type f > /usr/local/file.txt &
#!/bin/bash
password="aaaaa"
# Read the txt file line by line
while IFS= read -r line; do
# Remove any leading or trailing whitespace
line=$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# Extract the filename from the line
filename=$(basename "$line")
# Spawn the expect script
expect -c "
spawn scp \"$line\" [email protected]:/usr/local/file/video/oldvideo/$filename
expect {
\"*assword:\" {send \"$password\r\"; exp_continue}
\"yes/no\" {send \"yes\r\"; exp_continue}
\"No route to host\" {exit 1}
}
expect eof
"
done < file.txt