I have a script that should do a portscan on a specific UDP-Port and checks if the correct service string can be grepped upon. It looks like the following: Nmap returns the following (the same for root and User nagios):
Starting Nmap 6.40 ( http://nmap.org ) at 2019-02-23 12:33 CET Nmap scan report for 172.32.0.1 Host is up. PORT STATE SERVICE 1194/udp open|filtered openvpn Nmap done: 1 IP address (1 host up) scanned in 2.08 seconds
Now I grep it in the script:
f_result=`echo $result | egrep -o "${port}/udp [a-zA-Z0-9_-\| ]+Nmap done"`
and this is where I get confused. I didn't write it myself, I don't have the best KnowHow on bash. Because:
if I execute the script, at that part of the grep, one User reports an error, the other doesn't. The script works for user root just fine, but for user "nagios", it returns:
egrep: Invalid range end
The Error has to be arount the backslash, but I don't get it, how can it work with rot but not as a different user? Is it some kind of forbidden symbol?
I guess it's a Layer 8 Problem, so I'm sorry if it's a kind of silly question to ask.