LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 05-19-2010, 05:34 AM   #1
njain
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Rep: Reputation: 0
shell script for a partial control over inputs to an external program


Hi all,

I've a software written by a third party (for linux distros, Ubuntu to be precise). This program executes while asking for user input (via stdin) at various stages of its running.
Now, a few of these stages/steps can be automated because the user input required is always the same. The other stages have varying inputs that depend on the outcome of some measurements from the previous stages; and so, have to be entered on-the-fly.
To elaborate, one can roughly describe the running of the program in this fashion:

Init:
Step0 - User input fixed
Step1 - User input fixed
Step2 - User input variable

Run:
Step3 - User input fixed
Step4 - User input fixed
Step5 - User input fixed
Step6 - User input fixed (and one can choose here either to return to Step3 or proceed to Step7)

Step7 - User input fixed
Step8 - User input variable
Step9 - User input variable

Close:
Step10

So, I wish to automate the Run portion from Step3 to Step6 now... the picture I've in my mind is of a shell script which runs in the background, parsing the stdout of the program (mainly textual in nature) and lets the program start in the usual way for the Init steps i.e. waits for the user to enter the input via stdin for Step0 to Step2.
From then on, it runs for say 5000 times, but now picking the input parameters from a file instead (created accordingly, to run Step3 to Step6 in a loop for 5000 times) and then at the 5001st instant, chooses to proceed to Step7.

I had had some exposure to linux shell programming quite long ago, but that seems enough to convince me that coding the above shouldn't be very hard ;-) but I look forward to your tips, pointers and suggestions on how to do it in the best possible way.

Thanks very much in advance,
Nitin
 
Old 05-19-2010, 08:57 PM   #2
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,244

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
There is only one programming language I that can do this, expect. Of course it is a far cry from Bash, and you must spend two evenings going thru a Tcl tutorial, but it works very reliable.

http://www.tcl.tk/man/expect5.31/expect.1.html

jlinkels
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
running a shell script which invokes another shell program!!! raghu123 Programming 1 08-04-2008 10:10 AM
shell script inputs aloishis89 Programming 3 03-10-2008 03:23 AM
Apache2 refuses control inputs IMS_Scott Linux - Server 3 11-28-2006 07:32 AM
! HELP ! Script : How to control parent shell ??? fawqati Programming 1 06-03-2006 01:58 PM
Shell Script to control logins NIkss Programming 9 12-17-2003 01:53 PM


All times are GMT -5. The time now is 11:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration