How to implement a stdin, stdout wrapper?

前端 未结 4 2170
挽巷
挽巷 2021-02-10 10:57

I have an interactive program that runs stdin and stdout. I need to create wrapper that will send X to it\'s stdin, check that it prints Y and then redirects wrapper\'s stdin an

4条回答
  •  鱼传尺愫
    2021-02-10 11:19

    Assuming X and Y are files, and that you can invoke the program more than once:

    #!/bin/bash
    
    test "`program 

    Or, to fail more verbosely:

    #!/bin/bash
    
    if [[ `program 

    If you only invoke the program once, Expect is a much simpler alternative than reassigning standard file I/O on the fly.

提交回复
热议问题