- ##########################备份############################
- #!/bin/bash
- srcdir=/home
- bakdir=/tmp/
- date="home"`date +%Y%m%d`
- tar -czvf $bakdir$date.tar.gz $srcdir
- ##########################################################
- #########################上传##############################
- #!/usr/bin/expect
- spawn ftp xxx.xxx.xxx.xxx
- expect "Name"
- send "ftp1\\r"
- expect "Password"
- send "passwd\\r"
- expect "logined"
- send "cd pub\\r"
- expect "changed"
- send "lcd /tmp\\r"
- expect "changed"
- send "prompt off\\r"
- send "mput *.tar.tz\\r"
- expect "send OK"
- send "bye\\r"
- #该片段来自于http://www.codesnippet.cn/detail/190420132911.html
来源: http://www.codesnippet.cn/detail/190420132911.html