Auto File transfer/copying with SCP

Here is a

Here is a script (below) you can use to copy dump files between machines using scp from an
automated script. Please see attached. The script usage is as
follows:

./auto_scp.sh  
local_file   user@host:remote_folder  
user_password

or

./auto_scp.sh  
user@host:remote_file   local_folder  
user_password

Example:

./auto_scp.sh   dump.dmp   oracle@hostname:/U01/oracle
  <oracle password>

and here is the script
————————————————–

#!/usr/bin/expect -f

# connect via scp
spawn scp "[lindex $argv 0]" "[lindex $argv 1]"
#############################################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "[lindex $argv 2]\r"
}
}
interact

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>