LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-12-2018, 03:22 AM   #1
gilbertodasilvaung
LQ Newbie
 
Registered: Nov 2018
Posts: 1

Rep: Reputation: Disabled
Nmap os detection with conditional criteria


Hello all,

I'm a newbie on linux. As I'm trying to make a list to get the OS of all servers in all subnet.

I tried this

Nmap -A -p T:22,25,39 172.16.*.* | awk'/report for|running:/'

Result:
Nmap scan report for server1 (172.168.1.1)
Running: Microsoft windows 2008
.....
....
..

Finally I got a long list including OS windows and linux. Could I set any if clause to get only linux OS in all subnet and output as a csv?
Moreover, other question about awk, could I have the display format that just retrieve IP hostname and OS ?
Like server1 172.16.1.1 linux 3.X
Server1 172.16.2.2 linux 3.X

Many thanks!
 
Old 11-12-2018, 01:06 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Welcome to LQ!

Quote:
Originally Posted by gilbertodasilvaung View Post
Finally I got a long list including OS windows and linux. Could I set any if clause to get only linux OS in all subnet and output as a csv?
Moreover, other question about awk, could I have the display format that just retrieve IP hostname and OS ?
The answer to all is of course, yes - you can filter and format the output data stream just about any way you want!

Awk is often the tool of choice for such operations, so you are on the right track! Getting the desired data selections is all about field separators, record separators and matching expressions which are most often given as regular expressions. So searching for those terms and review of the awk documentation (man awk) will get you started.

I am not familiar enough with namap options and output to offer any specific tips, but perhaps others with that knowledge will offer their advice.

LQ is all about sharing knowledge and getting help with specific problems, not so much about giving/getting complete working code. So you will get more active participation in your threads and more specific replies when you research the task yourself and try to work out a solution, then ask questions about specific things that you cannot figure out and show us what you have already tried.

You may want to review the Site FAQ for guidance in posting your questions and general forum usage. Especially, read the link in that page, How To Ask Questions The Smart Way. The more effort you put into understanding your problem and framing your questions, the better others can help!

Good luck!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
port 5432 open nmap online but closed status with firewalld and local nmap scan mtdew3q Linux - Security 6 06-04-2018 06:20 PM
nmap ? how do i do nmap in linux ? command not found abbasakhtar Linux - Newbie 2 01-02-2011 01:08 AM
LXer: Learn how to use nmap, and nmap GUI, a great port scan tool LXer Syndicated Linux News 0 01-03-2008 09:10 AM
nmap increase send delay for nmap 4.20 matters Slackware 1 10-01-2007 11:37 PM
Cant nmap from but can nmap to procfs Linux - General 6 08-01-2006 02:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration