-1

i have a file consists of each word in a line.

eg:- file consists of

 9/20/16
 11:00
 vamsi

I want to make each line as an input to console when ever it waits for input eg:- console is like

PLEASE ENTER TODAY'S DATE : 9/20/16

PLEASE ENTER CURRENT TIME : 11:00

PLEASE ENTER USER NAME : vamsi

It should take input from the file line by line like above.

2 Answers2

0

Looks like you need Expect. It's commonly used to respond to interactive prompts in shell programs based on file input.

Community
  • 1
  • 1
l0b0
  • 55,365
  • 30
  • 138
  • 223
0

Simply use that file as input:

program < file

For example, I want to select my timezone using the tzselect tool. For my timezone, I need to enter

7
16
2
1

Saving this contents into input.txt, I can run tzselect with

tzselect < input.txt

This gives the same output as if the values have been typed in manually.

Martin Nyolt
  • 4,463
  • 3
  • 28
  • 36
  • i want to give input to a running script from a file. – vamsi krishna paruchuri Sep 22 '16 at 11:29
  • Yes. That was your question. My answer responds to that question. Stack Overflow is not a chat or forum. If you have a new question, ask a new question. If you feel your question has been misunderstood, *edit and improve* your question. Please be clear and precise. Your comment adds no new information and thus does not fit to the format of Stack Overflow. – Martin Nyolt Sep 22 '16 at 11:38