开发者

ncurses - expect: sleep executes at wrong time

开发者 https://www.devze.com 2022-12-19 18:13 出处:网络
I have some ncurses apps that I need to automate to test repeatedly. I am placing the \"sleep\" command between \"send\" commands. However, what i see is that all the开发者_高级运维 sleep\'s are execu

I have some ncurses apps that I need to automate to test repeatedly. I am placing the "sleep" command between "send" commands. However, what i see is that all the开发者_高级运维 sleep's are executed in the beginning before the screen loads. expect concatenates the sends (I see that at the screen bottom during sleep) then issues them together.

I have tried sending all keys with "send -s" or "send -h". That marginally helps. I've replaced "-f" on line 1 with "-b" - again a tiny difference.

Why isn't "sleep" pausing at the right time. Incidentally, my programs have a getc() loop, so i can't use "expect" command. I tried that too.

#!/usr/bin/expect -f
spawn ruby testsplit.rb
#expect
set send_human {3 3 5 5 7}
set send_slow {10 1}
exp_send -s -- "--"
exec sleep 3
send -s "+"
send -s "="
sleep 1
send -h -- "-"
send -h -- "-"
sleep 1
send -h  -- "v"
interact


I would guess that you need to wait for your ruby program to start up before you continue with the sends and sleeps. Is there any string the ruby program outputs when it has started (eg. "ready") ? If so, at the point where you have expect commented out I would try expect "ready" so that Expect will wait until the ruby program has started before continuing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号