LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-29-2016, 08:14 AM   #1
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 58

Rep: Reputation: Disabled
Question How to filter the success message when using nc port scan


I used following command for port scanning of my machine
Code:
nc -zv 192.168.1.1 1-100
but I want to filter only succeeded message from following output.Hence i used the following command
Code:
nc -zv 192.168.1.1 1-100|grep succeeded
But no improvement still it shows full output
 
Old 06-29-2016, 08:39 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,921

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by P.G.Krish View Post
I used following command for port scanning of my machine
Code:
nc -zv 192.168.1.1 1-100
but I want to filter only succeeded message from following output.Hence i used the following command
Code:
nc -zv 192.168.1.1 1-100|grep succeeded
But no improvement still it shows full output
Would help if you posted what, exactly, you're seeing, and what you WANT to see. If you pipe it into grep, it will show you EVERYTHING with the word "succeeded" on it, just as you asked it to. So if that's what it's doing, why are you expecting it to do anything else?

Show us what you get, and tell us what you WANT.
 
Old 06-29-2016, 09:38 AM   #3
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 58

Original Poster
Rep: Reputation: Disabled
I want to filter success message which is only when the ports are open .Many ports give error message, i dont want to see that , I only see the open ports
 
Old 06-29-2016, 09:48 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,921

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by P.G.Krish View Post
I want to filter success message which is only when the ports are open .Many ports give error message, i dont want to see that , I only see the open ports
And AGAIN....you need to post WHAT YOU ARE SEEING and what you WANT TO SEE. Re-stating your question and providing no additional information tells us nothing. Again, we can't guess.

Post a sample of the command output, and then post what you WANT to see.
 
Old 06-29-2016, 09:55 AM   #5
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 58

Original Poster
Rep: Reputation: Disabled
Red face It the output .I want to filter the particular line which has succeeded

Quote:
Originally Posted by TB0ne View Post
And AGAIN....you need to post WHAT YOU ARE SEEING and what you WANT TO SEE. Re-stating your question and providing no additional information tells us nothing. Again, we can't guess.

Post a sample of the command output, and then post what you WANT to see.
Code:
nc: connect to 192.168.1.1 port 1 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 2 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 3 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 4 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 5 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 6 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 7 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 8 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 9 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 10 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 11 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 12 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 13 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 14 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 15 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 16 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 17 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 18 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 19 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 20 (tcp) failed: Connection refused
Connection to 192.168.1.1 21 port [tcp/ftp] succeeded!
nc: connect to 192.168.1.1 port 22 (tcp) failed: Connection refused
 
Old 06-29-2016, 09:58 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,245

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
So, assuming you are saying that even with the grep you would get all of the above output and not just the 'succeeded' line, it could be that nc output to stderr and not stdout, so try a redirect
and see if that improves your results?
 
Old 06-29-2016, 10:09 AM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,921

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by P.G.Krish View Post
Code:
nc: connect to 192.168.1.1 port 1 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 2 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 3 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 4 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 5 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 6 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 7 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 8 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 9 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 10 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 11 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 12 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 13 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 14 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 15 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 16 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 17 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 18 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 19 (tcp) failed: Connection refused
nc: connect to 192.168.1.1 port 20 (tcp) failed: Connection refused
Connection to 192.168.1.1 21 port [tcp/ftp] succeeded!
nc: connect to 192.168.1.1 port 22 (tcp) failed: Connection refused
Great...so you were asked for:
  • What you SEE
  • What you WANT to see
...and posted that, and don't post what you WANT to see. Again, you're not posting what you're after, but based on your question, did you read the man pages on the nc command? nc outputs logs to stderr, so you need to redirect before grep'ing:
Code:
nc -zv <address> 1-100 2>&1 | grep succeeded
When people ask you to clarify things, and you don't, it's frustrating, and makes people NOT want to help you.
 
Old 06-29-2016, 10:27 AM   #8
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 58

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Great...so you were asked for:
  • What you SEE
  • What you WANT to see
...and posted that, and don't post what you WANT to see. Again, you're not posting what you're after, but based on your question, did you read the man pages on the nc command? nc outputs logs to stderr, so you need to redirect before grep'ing:
Code:
nc -zv <address> 1-100 2>&1 | grep succeeded
When people ask you to clarify things, and you don't, it's frustrating, and makes people NOT want to help you.
Thanks TB0ne , i will correct my mistakes.
 
  


Reply

Tags
commandline, nc, terminal


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Shell script to Continuously scan a log file for success novice82 Linux - Newbie 4 10-09-2009 03:20 AM
Any success with on-access virus scan, clam, klam, Trouble installing dazuko module. GlennsPref Mandriva 2 11-08-2008 06:14 PM
Nessus scan and no port scan possible? memo007 Linux - Security 1 09-08-2008 07:21 PM
best port scanner To scan open port in a network tanveer Linux - Security 8 01-21-2007 09:19 PM
Port Scan: Closed Port instead of Stealth unihiekka Linux - Security 9 12-26-2005 09:51 PM


All times are GMT -5. The time now is 08:12 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration