I have the following in an expect scriptspawn cat versionexpect -re 5.*.*set VERSION $expect_out(0,string)spawn rpm --addsign dist/foo-$VERSION-1.i686.rpmThe cat command is getting the version correctly however it appears to be adding a new line. Since I expect the output to be the following:dist/foo-5.x.x-1.i686.rpmbut am getting including the error at the begining the following:cannot access file dist/foo-5.x.x-1.i686.rpmWhy is expect adding a new line to the cat command output and is there any way to have this not be done or to fix the output of the cat command?
Cat in expect script adds new line to end of string
linux;cat;output;newlines;expect
TCL can read a file directly without the complication of 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