これを機能させることができず、その理由がわかりません。行末の数字の間にスペースがある行があります。この行に一致することを期待して、数字とスペースをキャプチャ グループに入れる必要があり、スクリプトの後半でそのキャプチャ グループにアクセスする必要があります。
サンプル行は次のとおりです。これは行です 2 4 5 6
私のexpect -reステートメント:expect -re {^this\sis\sa\sline((\s\d)+$)}
次に、$expect_out(1,string) を使用してキャプチャ グループにアクセスしようとしています。
http://gskinner.com/RegExr/を確認すると、一致グループ 1 は「2 4 5 6」であると表示されているため、パターンが正しく一致していると確信しており、$ に「2 4 5 6」が表示されると予想されます。 expect_out(1,string) ですね。
ただし、expect スクリプトを実行すると、次のように表示されます。
expect: does " \u001b[Js\u001b[Jt\u001b[Jr\u001b[Je\u001b[Ja\u001b[Jm\u001b[Js\u001b[J\r\n\u001b[H\u001b[J\r\n\r\n\r\n\r\this is a line 2 4 5 6\r\n\r\nSelect which option you would like to change\r\nusing the index number: " (spawn_id exp5) match regular expression "^this\sis\sa\sline((\s\d)+$)"? Gate "this?is?a?line*"? gate=yes re=no
expect: timed out
can't read "expect_out(1,string)": no such element in array
while executing
"set streams $expect_out(1,string)"
(file "check-config" line 35)
"2 4 5 6" (または " 2 4 5 6") を変数に入れて、後で期待スクリプトで使用するにはどうすればよいですか?
また、私はあなたの注意を引いていますが、どういうGate=Yes re=No
意味ですか? re=No は正規表現が一致しなかったことを意味すると思いますがGate
、Expect の世界では何ですか?