Script program inputs in bash ubuntu linux

I'm in a course for C++ programming.

Our professor created a linux validation script against which our program output must match exactly.

It's running out of his own program and generates an output.txt file, then compares it against his output file, if it doesn't match it rejects the script.

The problem is, this program excepts probably 150-200 lines of input and if anything goes in wrong you have to start all over again. If you even enter an incorrect char, it must be restarted as the backspace registers as a character of its own.

How might I generate a bash script that would feed all of the input into the program automatically?

NOTE: We have to use his program as in: ~professor.name/submit asigname

Answers


How might I generate a bash script that would feed all of the input into the program automatically?

Without any example code or input/output, it is hard to gauge what precisely is that you need.

Otherwise, for a generic tool to automate interactive console programs, I would suggest to take a look at the Expect.


You can create a text file:

answers.txt

answer1
answer2
...
answerN

and use that as stdin for the program:

./your_program < answers.txt

Need Your Help

Is there any other way to install Laravel or Yii without using the command prompt?

php yii frameworks laravel

Just need a little help here. Right now I am studying another framework. Before I am using CodeIgniter and Smarty as my development tools. But I decided to switch to another framework. My choices a...

document.getElementById working differently on iPad Safari?

javascript ios iphone ipad mobile-safari

I'm getting completely different behaviors in mobile Safari on the iPhone versus the iPad, both on actual hardware and in the iOS simulator, for document.getElementById.