math
任意の数学問題を生成して印刷し、入力を待つプログラムがあるとします。
入力を受け取り、処理して元のプログラムに再印刷するスクリプトを作成するにはどうすればよいですか?
私はこのようなことを試しましたが、
./math | script.sh | ./math
2番目のプログラムは他の問題を引き起こして動作しませんでした。
ベストアンサー1
サンプル出力や動作がなければ、正確な応答を提供するのは難しいですが、コマンドを探しているようですexpect
。
マンページ楽しみです(1):
EXPECT(1) General Commands Manual EXPECT(1)
NAME
expect - programmed dialogue with interactive programs, Version 5
SYNOPSIS
expect [ -dDinN ] [ -c cmds ] [ [ -[f|b] ] cmdfile ] [ args ]
INTRODUCTION
Expect is a program that "talks" to other interactive programs accord‐
ing to a script. Following the script, Expect knows what can be
expected from a program and what the correct response should be. An
interpreted language provides branching and high-level control struc‐
tures to direct the dialogue. In addition, the user can take control
and interact directly when desired, afterward returning control to the
script.