Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

Problem with 'string match' and variable

$
0
0

I've been searching for hours and trying multiple things. This is the expect code snippet which works.

         foreach line [split $expect_out(buffer) \r\n] {            if {[string match {*word*} $line]} {               send_user "$line\r\n"               set acctnum [exec echo $line | cut -d\. -f1]               send_user "$acctnum\n\r"            }         }

The output is:

2. word2

"word" without the asterisks and "word" with an asterisk on either end does not work. I need this to be a variable which is provided on the command line. I have found no combination which will work with a variable.

Please provide suggestions to get this to work.


Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>