I have a text file where i have the list of logins and passwords in the form:
login1:pass1
login2:pass2
But the script copy only the file from the first login(sometimes don't copy anything)
and stops in the first iteration of while… as if the expect have break of c/c++
The code without the while, works fine.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you try creating the script differently? Instead of having a bash script use expect to do this, make an expect script to do it. Have expect open the text file of logins and passwords, have expect loop through them and copy the files.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, i want to copy a file from various accounts on a server, and save each file in differents directories.Then i write a bash script :
<pre><code>#!/bin/bash
FILE=$1
HOST=$2
IFS=:
while read LOGIN PASS
do
mkdir $LOGIN
expect -c "
spawn scp $LOGIN@$HOST:programas/$FILE $LOGIN/$FILE
expect {
"*password:*" { send $PASS\r\n; interact }
eof { exit }
}
"
done< iplogins.txt
I have a text file where i have the list of logins and passwords in the form:
login1:pass1
login2:pass2
But the script copy only the file from the first login(sometimes don't copy anything)
and stops in the first iteration of while… as if the expect have break of c/c++
The code without the while, works fine.
Can you try creating the script differently? Instead of having a bash script use expect to do this, make an expect script to do it. Have expect open the text file of logins and passwords, have expect loop through them and copy the files.