[plug] send keystrokes to console program on execution line

Anthony Woods anthony at monkey.id.au
Tue Aug 2 12:55:35 WST 2011


On Tue, Aug 2, 2011 at 10:10 AM, Shanon Loughton <autobot at iinet.net.au> wrote:
>
> On Tue, Aug 2, 2011 at 9:27 AM, byteme-its <byteme-its at westnet.com.au>
> wrote:
>>
>> Hi Shannon
>>
>> ----- Original Message -----
>> From: "Adrian Chadd" <adrian at creative.net.au>
>> Sent: Monday, 1 August, 2011 7:30:49 PM GMT +08:00 Beijing / Chongqing /
>> Hong Kong / Urumqi
>> Subject: Re: [plug] send keystrokes to console program on execution line
>>
>> Google "expect" ?
>>
>> On Mon, Aug 01, 2011, Shanon Loughton wrote:
>> > HI everyone
>> >
>> > Id like to run a simple terminal program and supply the keystrokes
>> > needed to
>> > kick it along, all in one line. Specifically its GLmark (
>> > http://sourceforge.net/projects/glmark/) (I know, out of date...)
>> > and it needs something like this wrt keystrokes after running from its
>> > directory:
>> >
>> > $ ./glmark [enter]
>> > 400 [enter]
>> > 300 [enter]
>> > 16 [enter]
>> > 1 [enter]
>>
>> As Adrian said, look up expect. It should be in most repositories, debian:
>> apt-get install expect
>>
>> basically expect replaces the #!/bin/bash at the top of your "script" ie
>> #!/bin/expect.
>>
>> then you give it some commands: Start the program, expect this, send
>> that... I use it for monitoring several programs, including a script I have
>> written to shut down kids computers and downloading programs from the abc
>> iview site...
>>
>> Regards,
>>
>> Adam Davin
>> Byteme IT Services.
>>
>> _______________________________________________
>> PLUG discussion list: plug at plug.org.au
>> http://lists.plug.org.au/mailman/listinfo/plug
>> Committee e-mail: committee at plug.linux.org.au
>
>
> Thanks everyone
>
> 'expect' appears to be the thing im looking for. However I cant figure out
> what the sleep/wait/exit should be at the end of the script for this
> 'glmark' program as it spawns a child (I think) window after the small
> amount of input. With an 'exit' it stops/kills the program before child has
> a chance to display, with a 'wait' does the same thing, with a 'sleep 20'
> nothing happens for 20 seconds then same result as the first two.
>
> script:
> #!/usr/bin/expect -f
>
> spawn /home/username/GLMark-0.5.2.1/glmark
>
> expect "Enter screen width: "
>
> send "400\r"
>
> expect "Enter screen height: "
>
> send "300\r"
>
> expect "Enter screen bpp: "
>
> send "16\r"
>
> expect "Enter '1' for fullscreen '0' for windowed:"
>
> send "0\r"
>
> sleep 20 # or wait?
>
> Anyway, the discussion is just trivial now - theres a glmark2 package that
> runs the way I want by default without input so thats what Ill use. Still,
> would be interesting to know the answer.
>
> cheers
> Shanon
>

Hi Shanon,


Use "interact" at the end of the expect script.

http://wiki.tcl.tk/3914

-
Anthony



More information about the plug mailing list