Using `grep+sort+head -n1` instead of `grep -m1` permit, if a port is
listening on multiple interfaces (127.0.0.1:25, 192.168.0.1:25, *:25) to print the most generic one (*:25).
This commit is contained in:
		
							parent
							
								
									566450407e
								
							
						
					
					
						commit
						eac6b98bac
					
				
							
								
								
									
										3
									
								
								dynmotd
								
								
								
								
							
							
						
						
									
										3
									
								
								dynmotd
								
								
								
								
							|  | @ -56,7 +56,8 @@ service_info() { | |||
|     # If a port listen | ||||
|     if (ss -lutn|grep -m1 ":${PORT}" > /dev/null); then | ||||
|       # Example: "tcp/127.0.0.1:25" | ||||
|       MSG="${MSG}${GREEN}$(ss -lutn|grep -m1 ":${PORT}"|awk '{print $1"/"$5}')${RESET} " | ||||
|       #MSG="${MSG}${GREEN}$(ss -lutn|grep -m1 ":${PORT}"|awk '{print $1"/"$5}')${RESET} " | ||||
|       MSG="${MSG}${GREEN}$(ss -lutn|grep ${PORT}|sort|head -n1|awk '{print $1"/"$5}')${RESET} " | ||||
|     else | ||||
|       # Example: "22: NOT LISTENING" | ||||
|       MSG="${MSG}${REDB}${PORT}: NOT LISTENING${RESET} " | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue