Monday, March 1, 2010

Auto Copy a file to destination host

[root@tas5 astelit]# cat /root/scripts/cleanupcopy.sh
#!/usr/bin/expect -f
# connect via scp
spawn scp /space/cleanupOpendsExport.ldif root@10.1.11.1:/space/
#######################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "myPassword\r"
}
}
interact
[root@tas5 astelit]# ENJOY WITH IT :-)
NOTE: This script is copying the local file {/space/cleanupOpendsExport.ldif} to the destination host with IP {10.1.11.1} without entering password.Destination host username is {root} and its password is {myPassword}, destination folder is /space

No comments:

Post a Comment