Sending keystroke through script.

Posted on 2009-02-12
Last Modified: 2013-11-10

I need help sending a keystroke from a shell script. My script telnets into a server's serial console. I have this part down. Then I need to send the keystroke combination "Esc+(" to redirect me to the server's iLo/BMC interface. (I need to simulate pressing the keystroke for opening parenthesis while the Escape key is depressed) I don't know how to send keystrokes from a simple linux script. I am not allowed to install any new packages and would really like to keep this as a script and not a c program. I don't need the script to 'expect' anything, just send the keystroke.

Question by:zkolev
    LVL 48

    Accepted Solution

    You could try

    (echo -e "\033(") | telnet server
    LVL 34

    Expert Comment

    by:Duncan Roe
    Is this in a GUI normally? X can detect arbitrary key press combinations, but there is no ASCII equivalent. If you touch the Escape key, you will get an Ec (033) character. If you hold it down, you may get many depending on your console settings: whether key repeat is on and what is the frequency. If in the meantime you press "(", you may get one, interspersed with the escapes.
    In brief, you can't send key press events to a serial console.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    This article will show, step by step, how to integrate R code into a R Sweave document
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now