[Snort-users] Getting Snort version as bash variable

Rob MacGregor rob.macgregor at ...11827...
Wed Aug 4 04:56:04 EDT 2010

On Wed, Aug 4, 2010 at 06:37, CoryC <oakleeman at ...131...> wrote:
> Last week someone wrote that they used a script to do automatic updates of Snort. I'm trying to do something similar but am having difficulty capturing the version number as a Bash variable. I can capture the whole version string & ascii art but can't figure out how to manipulate it to give me just the version number. I'm unable to echo the string into a text file either, it shows all the info on the screen.
> I was getting it from the snort.conf file but I didn't see it written in the latest version so I thought I'd get it from the -V method.
> I've google searched but might be using the wrong terms since I've not had much luck. Any advice would be appreciated.

snort -V 2>&1 | egrep Version | sed "s/.*Version \([0-9\.]*\) .*/\1"

Should do the trick (caution, that wasn't a copy and paste, some minor
tweaking may be required).  Basically, it redirects stderr to stdout,
extracts only the line with the word Version in it and then extracts
the field after the word Version, that consists only of numbers and
dots.  If Snort were to move to including letters in the version you'd

snort -V 2>&1 | egrep Version | sed "s/.*Version //" | awk '{ print $1 }'

Which does much the same, only it extracts the space delimited field
after the word Version.

                 Please keep list traffic on the list.

Rob MacGregor
      Whoever fights monsters should see to it that in the process he
        doesn't become a monster.                  Friedrich Nietzsche

More information about the Snort-users mailing list