Script that calls ausearch behaves differently when piped data on stdin

前端 未结 2 2029
一整个雨季
一整个雨季 2021-01-15 17:59

Can someone explain why passing a bash script data via STDIN would cause the command within the script to NOT function?

Script:

#!/bin/bash
ausearch          


        
2条回答
  •  时光说笑
    2021-01-15 18:02

    Nothing is wrong with bash, stdin, or your script. ausearch's behavior is the cause.

    The ausearch utility can also take input from stdin as long as the input is the raw log data.

    See the ausearch manpage: http://man7.org/linux/man-pages/man8/ausearch.8.html

    Your script is passing the args just as it should but because of the pipe ausearch is only reading "blah" from stdin and not the default logfiles and giving no matches.

    If you need this to not happen use SOMEVAR=$(cat /dev/stdin) to capture stdin in bash and pass it to ausearch or any other part of the script as $SOMEVAR.

提交回复
热议问题