How do I use a date in an Expect script?

In Expect, you would use the builtin clock command:

set now [clock seconds]
set date [clock format $now -format {%b-%d}]
set file file.$date

Or in one go:

set file file.[clock format [clock seconds] -format {%b-%d}]

I would strongly encourage you to use a date format that sorts sensibly

set file file.[clock format [clock seconds] -format {%Y-%m-%d}]

Cut from an Expect script:

# Set DATE variable in expect script
set DATE [exec date +%F]
send "This is a test with Expect on $DATE - try 4\r"
send ".\r"

Tags:

Expect