Reputation: 1863
What I need to do is to set a variable at the beginning of an expect script to a value which depends on th size of a file. What I need to do is something like this:
set filesize `stat -c%s foo.bin`
set factor 42
set timeout $filesize / $factor
I already searched around for some tutorials, but searching the keywords 'expect' and 'calculation' are too common, so the search results do not face the unix binary /usr/bin/expect.
How to do some calculation in expect script?
Upvotes: 0
Views: 585
Reputation: 246774
No need to call out to stat
:
set filesize [file size foo.bin]
See https://tcl.tk/man/tcl8.6/TclCmd/file.htm#M34
Upvotes: 2
Reputation: 20688
Expect uses Tcl so you also need to learn Tcl's manual.
To quickly help you out:
set filesize [exec stat -c%s foo.bin]
set factor 42
set timeout [expr {$filesize / $factor}]
Upvotes: 1