Reputation: 1694
Given a process which accept command line input as below
$ ./app
> init
initialized.
> start
started.
> stop
stopped.
Is it possible to write a shell script or another C program which trigger ./app, and inject command sequentially? Let say the script-to-be-written will inject string "init", and wait for reply string "initialized.", then inject "start", and wait for reply "started.", and so on.
Upvotes: 1
Views: 91
Reputation: 66263
The Unix expect
tool has been created for exactly this scenario. You provide a script where you state the expected string (like initialized
) and declare the appropriate action following that string. Of course there is also some kind of "START" thing.
See http://en.wikipedia.org/wiki/Expect for examples.
Upvotes: 1