Queueing keystrokes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Queueing keystrokes
# 1  
Old 06-02-2009
Queueing keystrokes

Hello,
I have a ksh which can be run interactively with read etc waiting for input and so forth.
Do you have an idea how can I invoke the ksh and supply a sequence of keystrokes that will feed the executable flow so that it will automatically run as if someone actually walked through one prompt at a time, responding to them?
I hope this is possible, it almost seem that I should place all of the readable responses to reads etc into a buffer and that will feed the reads etc.
Is it something that can be done?

Please let me know.

Thanks alot!
# 2  
Old 06-02-2009
Quote:
Originally Posted by gio001
Hello,
I have a ksh which can be run interactively with read etc waiting for input and so forth.
Do you have an idea how can I invoke the ksh and supply a sequence of keystrokes that will feed the executable flow so that it will automatically run as if someone actually walked through one prompt at a time, responding to them?
I hope this is possible, it almost seem that I should place all of the readable responses to reads etc into a buffer and that will feed the reads etc.
Is it something that can be done?

Pipe the repsonses.

To provide a stream of ys:

Code:
yes | your_script

To provide a stream of ns:

Code:
yes n | your_script

To provide a mixed bag:

Code:
printf "%s\n" a b c d e f ... | your_script

# 3  
Old 06-02-2009
Well, I tryed your suggestions, but it does not seem to work properly.
The first prompt to be answered in the flow of the ksh is a select statement where a 'menu' is displayed and the prompt is to pick one of the choices. I tried various approaches on piping the selection to the ksh. at execution time what I get is a is a looping of the menu on the screen over and over, it seems my choice gets received but not properly interpreted by the ksh.
Any idea?
Thanks.
# 4  
Old 06-02-2009
Quote:
Originally Posted by gio001
Any idea?

Not without seeing the script.
# 5  
Old 06-02-2009
Great, I think I got it to work using your suggestion of the printf and piping something like:
printf "%s\n%s\n%s\n\n%s\n" 5 1 4 q | myname.ksh
this is executing like I started my ksh pressed 5 followed by enter,1 followed by enter,4 followed by enter, another enter and finally a q followed by enter.

One more question: how can I code a way to understand inside the script that itself has been invoked with a piped input or know is has been invoked by itself (no piped input) and therefore there is a user driving at the keyboard?
I really hope you have an idea.
Thanks.
# 6  
Old 06-02-2009
Not sure why you need this in this context, but.....
Code:
#!/bin/ksh

if [ ! -t 0 ]; then
   echo 'no term, i.e. piped'
fi;

# 7  
Old 06-02-2009
Quote:
Originally Posted by gio001
Great, I think I got it to work using your suggestion of the printf and piping something like:
printf "%s\n%s\n%s\n\n%s\n" 5 1 4 q | myname.ksh

This is the same and looks neater:

Code:
printf "%s\n" 5 1 4 "" q | myname.ksh


Last edited by cfajohnson; 06-02-2009 at 03:03 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Record and re-use keystrokes

We have a FORTRAN program that creates a report for our client. The client makes a number of selections as to what will appear on the report. However, the client has to repeat this everytime the report is run. I am trying to find a way to record what they've selected (their keystrokes) in UNIX and... (22 Replies)
Discussion started by: KathyB148
22 Replies

2. UNIX for Advanced & Expert Users

Sending keystrokes to another process

The third-party ERP system used by our company has no idle-out facility and we sometimes have issues because users simply walk away from their computers and leave sessions logged in for hours or even go home without logging out. (We are in a factory environment so it is hard to raise the care... (7 Replies)
Discussion started by: Wayne Ivory
7 Replies

3. Programming

How do you detect keystrokes in canonical mode?

I'm writing a command shell, and I want to be able to detect when the user presses an arrow key (otherwise it just prints [[A, [[B, etc.). I know it's relatively easy (although somewhat more time-consuming) to detect keystrokes in noncanonical mode, but I've noticed that the bash shell detects... (4 Replies)
Discussion started by: Ultrix
4 Replies

4. OS X (Apple)

Any mac software for recording keystrokes

I'm trying to find a good keylogger that doesn't come with any viruses. It happens to me several times that my browser crashes when I am in article writing or some other thing, very annoying. Thus, I need a keylogger to keep all my keystroke recorded. I 'v tried some, like the Aobo Mac Keylogger,... (1 Reply)
Discussion started by: Bluerosen
1 Replies

5. UNIX for Advanced & Expert Users

How to implements Queueing Using Shell scripts

I want to implement a control mechanism using Shell scripts .The intention is to have controlled number of jobs running in parallel External process will kickstart 40 jobs in parallel .All the 40 jobs will call the same generic script with different parameter values .But at a time only 2 should... (1 Reply)
Discussion started by: police
1 Replies

6. UNIX for Dummies Questions & Answers

Looking for an X11 Utility - Send Keystrokes to Multiple Clients

A long time ago, I frequently used a small X11 utility that allows you to manage multiple systems at the same time. It worked by opening a small window that had a button you used to "Add" X Clients to it. These would be xterms on different systems for example. You would then type inside that... (5 Replies)
Discussion started by: Alon.Albert
5 Replies

7. Shell Programming and Scripting

tool to emulate keystrokes out to a ps/2 device?

hey all, i am trying to connect my mac to my sony DVD changer so that i can control one aspect of it with any kind of shell script or program. the DVD player allows you to plug in a PS/2 keyboard to navigate it's on screen menu. what i want to do is use my mac to navigate my own menus, then... (0 Replies)
Discussion started by: drzoomn
0 Replies

8. UNIX for Dummies Questions & Answers

recording keystrokes in vi

What is the syntax for recording command in vi. If I want to repeat a command over and over. My file is 12/01/05,,adsmte,9,0,0 12/02/05,,adsmte,12,0,0 12/03/05,,adsmte,10,0,0 12/04/05,,adsmte,11,0,0 12/05/05,,adsmte,10,0,0 12/06/05,,adsmte,10,0,0 12/01/05,,tsmpc1,57,1,2... (5 Replies)
Discussion started by: reggiej
5 Replies

9. UNIX for Dummies Questions & Answers

Message from queueing system

Every time a job is deleted from a queue a message resembling the following is sent to the job owner's terminal or mailed to the job owner if the job owner is not logged on: Message from root on 'hostname' (UNKNOWN) ... Message from queueing system: Job number '#' has been... (0 Replies)
Discussion started by: alab
0 Replies

10. AIX

Cannot find answer - stop queueing messages?

My root mail fills up very quickly because we have hundreds of remote printers and whenever a job is deleted, moved or a printer is down, up, sidways (jk) the queueing system drops root and email. It fills up super fast and is causing a problem. Rembak is the backend but i cannot find a way... (2 Replies)
Discussion started by: albertaguirre
2 Replies
Login or Register to Ask a Question