5.7.15

Script to automatize Secure Copy - SCP

Here a fast script, implemented using expect, that I use to automatize copy from a remote server using scp.

#!/usr/bin/expect -f
spawn scp -P port_number user@address:/file /home/file

expect { -re ".*sword.*" { exp_send "PASSWORD\r" } }

interact

It works without asking password to the user if you insert it in the 'PASSWORD' placeholder.
You can schedule as cronjob and you'll have a simply way to backup some of your remote files, maybe logs for later inspection.

Nessun commento:

Posta un commento