Skip to content

Instantly share code, notes, and snippets.

@mariolopjr
Created November 18, 2015 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariolopjr/1f4479df0e20496bcd86 to your computer and use it in GitHub Desktop.
Save mariolopjr/1f4479df0e20496bcd86 to your computer and use it in GitHub Desktop.
Automate SCP
#!/usr/bin/expect -f
#
# Author: Mario Lopez
# Based upon: http://blogs.oracle.com/SanthoshK/entry/automate_linux_scp_command, modified for my own use
# Ex: autoscp "user@example.com:/source/dir/" "/target/dir" "PASSWORD"
#
# connect via scp
spawn scp $1 $2
#######################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send $3+="\r"
}
}
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment