Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
I need a tool that will automate a GUI-based program running on linux. I have seen programs such as Xnee, however the product I test runs on a very stripped-down ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    3

    Need a tool to record keystrokes and replay them

    I need a tool that will automate a GUI-based program running on linux. I have seen programs such as Xnee, however the product I test runs on a very stripped-down version of linux (think embedded), so the huge requirements to run Xnee (GTK2.0+, among others) is certainly out of the question.

    Much of the GUI can be automated via the keyboard. The perfect tool that I can think of would be something that captures the keys pressed, and then have the ability to play them back. That is all -- KISS it, right?

    -Low number of dependencies (able to run on a 'bare bones' install)
    -Preferably recording capabilities (records your keystrokes)
    -Able to control and playback the keyboard (mouse only a bonus)

    Has anyone run across a tool that fits these requirements? Thanks

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    I have used command script, but not its companion replay. They run in a terminal window, no mouse capture that I know of ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Just Joined!
    Join Date
    Oct 2007
    Posts
    3
    The program is actually called "command script" and "replay"? Is there a link? Kinda hard to google since those are very general words

  4. #4
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    I look at the man pages. I would not expect the embedded system to have them, but I would expect a standard system to have them.

    In case you don't, here is a useful specific and general link script(1): - Linux man page and an example using script and scriptreplay (as replay is called in that system, mine was from Debian) Replaying terminal sessions with scriptreplay | LinuxInsight found with linux man replay Google leading to Linux.ByExamples and then to the article at linuxinsight ... cheers, drl
    Last edited by drl; 10-11-2007 at 04:53 PM. Reason: Add links
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  5. #5
    Just Joined!
    Join Date
    Oct 2007
    Posts
    3
    I just tried script and scriptreplay. Doesn't quite do what I wanted...

    Instead of actually simulating a keyboard stroke, it just saves the terminal session's output. So when you replay the file, it's not going to actually send the keystrokes to your application -- its just going to playback the output at the time you ran those commands.

    Thanks for the suggestion, though.... are there any other programs you're aware of that actually emulate the keyboard real time?

  6. #6
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    Hmmmm.

    Consider the result of a script capture of a session on file typescript:
    Code:
    % cat typescript
    Script started on Thu Oct 11 13:45:41 2007
    leap ~/try/script %
    leap ~/try/script % echo hi
    hi
    leap ~/try/script % wc
    
    leap ~/try/script % uname -a
    Linux leap 2.6.11-x1 #1 Mon Apr 25 12:13:32 EDT 2005 i686 GNU/Linux
    leap ~/try/script % echo hi | wc
          1       1       3
    leap ~/try/script % exit
    
    Script done on Thu Oct 11 13:46:11 2007
    Now I'm going to whack that with a perl hack:
    Code:
    #!/usr/bin/perl
    
    # @(#) p1       Extract commands from script session file typescript.
    
    use warnings;
    use strict;
    
    my($debug);
    $debug = 0;
    $debug = 1;
    
    my($lines) = 0;
    
    while ( <> ) {
            $lines++;
            next if not /%/;
            s/^.*%\s*//;
            print if /./xms;        # always use xms on matches
    }
    
    print STDERR " ( Lines read: $lines )\n";
    
    exit(0);
    Producing:
    Code:
    % ./p1 typescript
    
    echo hi
    wc
    uname -a
    echo hi | wc
    exit
     ( Lines read: 14 )
    Perhaps someone will stop by with a (far) better answer, and / or you can continue Googling for keyboard keystroke capture command script and so on.

    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  7. #7
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    drl's fine script will extract the shell commands and put them in a script. This is almost billybob00 wanted, with three reservations:
    1. It doesn't cover keyboard to input to actual programs (other than the shell itself);
    2. it will take everything after the %, on any line which contains one, whether it's a shell prompt or not; and
    3. since typescript ends each line with <CR><LF>, not just <LF>, that unusual line end will be replicated in the output from drl's script.

    I don't have an answer, billybob00, but you would do well to do this at the command line:
    Code:
    man expect
    If you can use drl's script to get a first cut at what you need, then maybe expect will fill the bill. At any rate, you should probably be familiar with what expect does.

  8. #8
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192

    print if /./xms; # always use xms on matches

    While I'm at it, I may as well comment on a comment in drl's script:
    Code:
    print if /./xms;        # always use xms on matches
    For the Perl aficionados among us, the five pattern modifiers documented in the third edition of the Camel book (the O'Reilly book Programming Perl) are:
    Code:
    /i      Ignore alphabetic case distinctions (case insensitive).
    /s      Let . match newline and ignore deprecated $* variable.
    /m      Let ^ and $ match next to embedded \n.
    /x      Ignore (most) whitespace and permit comments in pattern.
    /o      Compile pattern once only.
    Thank you, drl. I was not aware of a couple of these. I could have used /s a few times. For multiline data, /m looks useful. But I have grave doubts about using /x. Regular expressions are complicated enough without introducing muddiness into them. Best let them say exactly what you mean. (What does "(most) whitespace" mean, anyway? Makes me want to chew my fingernails.)

    This, obviously, is a religious issue.

  9. #9
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi, wje_lf.

    Most of my current perl coding habits come from the book below. For me, the book is near priceless ... cheers, drl
    Code:
    Title: Perl Best Practices
    Subtitle: Standards and Styles for Developing Maintainable Code
    Author: Damian Conway
    Date: 2005
    Publisher: O'Reilly
    ISBN: 0596001738
    Pages: 500
    Categories: perl, standard, development, scripting, programming
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  10. #10
    Just Joined!
    Join Date
    Oct 2007
    Posts
    1

    several tools

    I have a similar need and I found that xmacro does what you and I want.
    Have a look here (the page title and url are misleading ):
    A Search For Truth

    It's a good tutorial for the binary xmacro2

    Other packages that may help:
    bbkeys
    xremote
    keyboardcast

    Cheers

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...