Tuesday, May 3, 2011

how to automat scp script

Are you looking for a script which does not use ssh key generation and still be able to scp some files?

Advantages is that mostly user has access on one machine to generate ssh key but for the remote machine that is not possible.

Here is the script :

#!/usr/bin/expect -f

# connect via scp
spawn scp "user@example.com:/home/santhosh/file.dmp" /u01/dumps/file.dmp
#######################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "PASSWORD\r"
}
}
interact

#===========================================

Source

No comments:

Post a Comment