How to trick an application into thinking its stdout is a terminal, not a pipe

前端 未结 9 1623
梦如初夏
梦如初夏 2020-11-22 11:58

I\'m trying to do the opposite of \"Detect if stdin is a terminal or pipe?\".

I\'m running an application that\'s changing its output format because it detects a pip

9条回答
  •  时光说笑
    2020-11-22 12:32

    Aha!

    The script command does what we want...

    script --return --quiet -c "[executable string]" /dev/null
    

    Does the trick!

    Usage:
     script [options] [file]
    
    Make a typescript of a terminal session.
    
    Options:
     -a, --append                  append the output
     -c, --command        run command rather than interactive shell
     -e, --return                  return exit code of the child process
     -f, --flush                   run flush after each write
         --force                   use output file even when it is a link
     -q, --quiet                   be quiet
     -t[], --timing[=] output timing data to stderr or to FILE
     -h, --help                    display this help
     -V, --version                 display version
    

提交回复
热议问题