Emulating keystrokes

This is a discussion on Emulating keystrokes within the Linux Programming forums, part of the Platform Specific Boards category; Hi all, I have a program running on my gentoo system that controls a USB servosystem, however, it is a ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    1

    Emulating keystrokes

    Hi all,

    I have a program running on my gentoo system that controls a USB servosystem, however, it is a command line program that requires user input. I wish to use this program in the start up script of the computer so I was thinking there might be a way to emulate keystrokes to that program to fake a user input to the program and then exit. For example, to turn on the servosystem, you have to type (bold face represents user input)

    gentoo-machine root# ./aducmd 0
    Enter Command <pipe> <w|r|s> [Command] 1 w sk0
    Enter Command <pipe> <w|r|s> [Command] <Enter>
    gentoo-machine root#

    I thought of calling the program like this: echo -e "1 w sk0 \n \n" | ./aducmd 0 but that did not work, does any body know how to make a script or a command to fake user input? (or how to create one?)

    Thanks,
    Neked

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    Code:
    EXPECT(1)                                                            EXPECT(1)
    
    NAME
           expect - programmed dialogue with interactive programs, Version 5
    
    SYNOPSIS
           expect [ -dDinN ] [ -c cmds ] [ [ -[f|b] ] cmdfile ] [ args ]
    
    INTRODUCTION
           Expect  is  a  program  that "talks" to other interactive programs according to a script.
    Read the rest by typing
    man expect
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fake keystrokes to another process
    By Nota in forum Windows Programming
    Replies: 20
    Last Post: 01-26-2009, 10:56 PM
  2. Sending keystrokes to another view
    By azeemanwer in forum C++ Programming
    Replies: 2
    Last Post: 08-28-2007, 10:41 AM
  3. Send keystrokes to a running program via batch file
    By ganjamon in forum Windows Programming
    Replies: 2
    Last Post: 08-16-2005, 08:08 AM
  4. Tracking number of keystrokes
    By thecow in forum Windows Programming
    Replies: 4
    Last Post: 06-04-2003, 03:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21