I have an expect script to backup fortigate VDOM firewalls.
This works well, except the dynamic filename which is based on date output.
This is the script:
<!-- language: expect -->
#!/usr/bin/expect -f
##!/bin/bash
#DATE=$(date "+%Y.%m.%d")
#echo $DATE
set timeout 60
spawn ssh admin@vdom
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
The results of that script, is like:
VDOM1 # execute backup full-config tftp date "+%Y.%m.%d" ip.address
Can anyone help please?
Ok, I got the answer to the question on IRC (credit is to Venks):
`isn’t special in tcl.The correct way of doing it is like:
Hope this helps someone in the future.