Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to feed input to an interactive bash script from a text file [duplicate]

Tags:

bash

io

I have a script (from a vendor.. for masking passwords) that walks through a series of user inputs, and generates some output based on input. I would like to be able to wrap another script around it which feeds the input from a text file, and then captures the output for later use. Anyone have any examples of this?

UPDATE: I've done some digging, and it turns out the shell script is kicking off a java process which is what is requesting user input. xargs and <,>,| don't seem to work for this.

like image 325
etsauer Avatar asked Mar 15 '13 20:03

etsauer


1 Answers

myscript < input_file > output_file (from the command line) will read input_file line by line as if it were user input, and then write the output to output_file. Be careful though, if output_file already exists, it will be completely overwritten without any warning.

like image 135
Lorkenpeist Avatar answered Sep 18 '22 16:09

Lorkenpeist