Results 1 to 2 of 2
Hello, i want to copy a file from various accounts on a server, and save each file in different directories.Then i write a bash script :
Code:
#!/bin/bash
FILE=$1
HOST=$2
...
- 10-28-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 1
Copy remote files with expect and scp
Hello, i want to copy a file from various accounts on a server, and save each file in different directories.Then i write a bash script :
Code:#!/bin/bash FILE=$1 HOST=$2 IFS=: while read LOGIN PASS do mkdir $LOGIN expect -c " spawn scp $LOGIN(AT)$HOST:programas/$FILE $LOGIN/$FILE expect { "password:" { send $PASS\r\n; interact } eof { exit } } " done< iplogins
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, but i want to copy the file from all accounts, not one by one.
- 10-28-2009 #2
Instead of using expect to send a password to scp, why not use an ssh key pair to bypass password authentication altogether?


Reply With Quote