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
————————————————–

1
2
#!/usr/bin/expect -f</p>
<p># connect via scp<br />spawn scp "[lindex $argv 0]" "[lindex $argv 1]" <br />#############################################<br />expect {<br />-re ".*es.*o.*" {<br />exp_send "yes\r"<br />exp_continue<br />}<br />-re ".*sword.*" {<br />exp_send "[lindex $argv 2]\r"<br />}<br />}<br />interact<br />
#!/usr/bin/expect -f</p>
<p># connect via scp<br />spawn scp "[lindex $argv 0]" "[lindex $argv 1]" <br />#############################################<br />expect {<br />-re ".*es.*o.*" {<br />exp_send "yes\r"<br />exp_continue<br />}<br />-re ".*sword.*" {<br />exp_send "[lindex $argv 2]\r"<br />}<br />}<br />interact<br />