O TCL pode ler um arquivo diretamente sem a complicação de spawn cat
:
#!/usr/bin/env expect
# open a (read) filehandle to the "version" file... (will blow up if the file
# is not found)
set fh [open version]
# and this call handily discards the newline for us, and since we only need
# a single line, the first line, we're done.
set VERSION [gets $fh]
# sanity check value read before blindly using it...
if {![regexp {^5\.[0-9]+\.[0-9]+$} $VERSION]} {
error "version does not match 5.x.y"
}
puts "spawn rpm --addsign dist/foo-$VERSION-1.i686.rpm"