2
我有期望的脚本来备份fortigate VDOM防火墙。Expect脚本不会将日期命令的bash替换扩展为发送
这很好,除了基于日期输出的动态文件名。
这是脚本:
<!-- language: expect -->
#!/usr/bin/expect -f
##!/bin/bash
#DATE=$(date "+%Y.%m.%d")
#echo $DATE
set timeout 60
spawn ssh [email protected]
expect "password: $"
set send_slow {1 0.05}
send -s "pass\r"
send_user "pass\r"
send -s "config global\n"
send -s "execute backup full-config tftp `date \"+%Y.%m.%d\"` ip.address\n"
send -s "exit\n"
interact
该脚本的结果,是这样的: VDOM1#执行备份全配置TFTP date "+%Y.%m.%d"
ip.address
谁能帮助吗?