# Send keystrokes in console mode



## Reginald0 (Jul 24, 2003)

Hi, folks!

Is there any way (or application) to send keystrokes to buffer in console mode on Linux, like some programs do in command line mode on Windows? (i.e. sendkey.exe)
I want to automate some tasks that requires user intervention on my Linux systems, and I already tried to search on the net for something like this, but without success.
I would be greatly thankful if some of you show me a solution.

PS: Sorry about my poor english, I'm brazilian


----------



## gotissues68 (Sep 7, 2002)

What kind of tasks are you trying to automate? Probably something that a script could be written for or something that cron may do the trick for?


----------



## Reginald0 (Jul 24, 2003)

I wish to make a script that will be running all the time on a virtual console, with a user logged in, that will load a program called D3 (a database manager) at specific time, type the initial parameters asked for the program (interactively).
Then, after the program finish to start, type username and password, and the user gets access to program's prompt.
Then, execute a lot of commands, shutdown the program, and go back to script.
If you have any doubts about the process, please ask me.


----------



## gotissues68 (Sep 7, 2002)

Hmm thats going to be tough I'd think. You could setup a VNC session and run the DB manager as a background process, unless its a CLI app where its expects certain responses, then you might be able to write something in EXPECT language or using shell scripting..


----------



## Reginald0 (Jul 24, 2003)

gotissues68, D3 is a text mode application, and I think will work with Expect, despite I would like to avoid using it, cause I will have to spend some time to learn the basics of that language. You mentioned using shell scripting, and I prefer this cause I already did a lot of scripts, and for me will be more easy. If you know some way to do that, please teach me.
Thanks anyway.


----------



## gotissues68 (Sep 7, 2002)

I'm sure you could write a wrapper either in shell or perl, but there wouldn't have variables, it'd have to be repetetive stuff or possible prompt for the user info before it starts the software so the config is setup correctly for the session.


----------



## Reginald0 (Jul 24, 2003)

It's me again.

I finally decided to learn more about a program called "expect" that comes with the Red Hat CD-ROM and it does what I want. Moreover it's pretty easy to use.

Thanks a lot to "gotissues68" for his excelent tips.

Reginald0


----------



## gotissues68 (Sep 7, 2002)

I am glad I could help out Reginald. I'm sorry I couldn't just post 

#!/bin/sh
for i in what_regi_wants; do blah () fi;

Shell scripting is one of my weak areas at the moment heh.


----------

