#11 Scripting SCP with Expect
Expect is a great automation tool. It is especially good at scripting SCP, FTP, and other interactive programs.
In this episode we'll create a bash script using expect to automatically SCP a log file from a server. The script could be easily extended as a cron job and modified for other uses.
Uploaded on Nov 13, 2009 | 4:27 | Tags: expect ftp scp
#!/bin/bash
username="username"
password="password"
host="host"
path="/path/to/file"
expect -c "
spawn /usr/bin/scp $username@$host:$path .
expect {
"*password:*" {
send $password\r;
interact;
}
eof{
exit
}
}
"
If you enjoyed this episode, be sure to check out the newest Technicast on Apache2. All purchases support FOSSCasts.





